diff --git a/Buffs/Mounts/AndromedaBuff.cs b/Buffs/Mounts/AndromedaBuff.cs new file mode 100644 index 0000000000..27244854ec --- /dev/null +++ b/Buffs/Mounts/AndromedaBuff.cs @@ -0,0 +1,17 @@ +using CalamityMod.Items.Mounts; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Mounts +{ + public class AndromedaBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Andromeda"); + Description.SetDefault("You're controlling a piece of history"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + } +} diff --git a/Buffs/Mounts/AndromedaBuff.png b/Buffs/Mounts/AndromedaBuff.png new file mode 100644 index 0000000000..54f98b7bbf Binary files /dev/null and b/Buffs/Mounts/AndromedaBuff.png differ diff --git a/Buffs/Mounts/AndromedaSmallBuff.cs b/Buffs/Mounts/AndromedaSmallBuff.cs new file mode 100644 index 0000000000..b74a088387 --- /dev/null +++ b/Buffs/Mounts/AndromedaSmallBuff.cs @@ -0,0 +1,17 @@ +using CalamityMod.Items.Mounts; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Mounts +{ + public class AndromedaSmallBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Andromeda"); + Description.SetDefault("You're controlling a small piece of history"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + } +} diff --git a/Buffs/Mounts/AndromedaSmallBuff.png b/Buffs/Mounts/AndromedaSmallBuff.png new file mode 100644 index 0000000000..6d68533277 Binary files /dev/null and b/Buffs/Mounts/AndromedaSmallBuff.png differ diff --git a/Buffs/StatDebuffs/AndromedaCripple.cs b/Buffs/StatDebuffs/AndromedaCripple.cs new file mode 100644 index 0000000000..14b103e42b --- /dev/null +++ b/Buffs/StatDebuffs/AndromedaCripple.cs @@ -0,0 +1,19 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.StatDebuffs +{ + public class AndromedaCripple : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Andromeda Cripple"); + Description.SetDefault("You're slow"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + canBeCleared = false; + } + } +} diff --git a/Buffs/StatDebuffs/AndromedaCripple.png b/Buffs/StatDebuffs/AndromedaCripple.png new file mode 100644 index 0000000000..71c4ea3f1e Binary files /dev/null and b/Buffs/StatDebuffs/AndromedaCripple.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 75b854b93f..a45bfc6bb9 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -53,6 +53,8 @@ using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.IO; +using Terraria.ModLoader.Config; +using System.Linq; namespace CalamityMod.CalPlayer { @@ -69,6 +71,14 @@ namespace CalamityMod.CalPlayer Walk } + public enum AndromedaPlayerState + { + Inactive, + SmallRobot, + LargeRobot, + SpecialAttack + } + public class CalamityPlayer : ModPlayer { #region Variables @@ -236,6 +246,8 @@ namespace CalamityMod.CalPlayer public bool angryDog = false; public bool fab = false; public bool crysthamyr = false; + public AndromedaPlayerState andromedaState; + public int andromedaCripple; #endregion #region Pet @@ -1840,7 +1852,8 @@ namespace CalamityMod.CalPlayer deathModeUnderworldTime = 0; gaelRageCooldown = 0; gaelSwipes = 0; - gaelSwitchTimer = (GaelSwitchPhase)0; + gaelSwitchTimer = 0; + andromedaState = AndromedaPlayerState.Inactive; planarSpeedBoost = 0; galileoCooldown = 0; soundCooldown = 0; @@ -1861,6 +1874,7 @@ namespace CalamityMod.CalPlayer reforges = 0; polarisBoostCounter = 0; spectralVeilImmunity = 0; + andromedaCripple = 0; plaguedFuelPackCooldown = 0; plaguedFuelPackDash = 0; plaguedFuelPackDirection = 0; @@ -3586,6 +3600,23 @@ namespace CalamityMod.CalPlayer #region Pre Kill public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { + if (player.Calamity().andromedaState == AndromedaPlayerState.LargeRobot) + { + if (!Main.dedServ) + { + for (int i = 0; i < 40; i++) + { + Dust dust = Dust.NewDustPerfect(player.Center + Utils.NextVector2Circular(Main.rand, 60f, 90f), 133); + dust.velocity = Utils.NextVector2Circular(Main.rand, 4f, 4f); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 1.35f); + } + for (int i = 0; i < 3; i++) + { + Utils.PoofOfSmoke(player.Center + Utils.NextVector2Circular(Main.rand, 20f, 30f)); + } + } + } if (invincible && player.ActiveItem().type != ModContent.ItemType()) { if (player.statLife <= 0) @@ -6007,7 +6038,12 @@ namespace CalamityMod.CalPlayer public override void FrameEffects() { - if (snowRuffianSet) + if (player.Calamity().andromedaState == AndromedaPlayerState.LargeRobot || + player.Calamity().andromedaState == AndromedaPlayerState.SpecialAttack) + { + player.head = mod.GetEquipSlot("NoHead", EquipType.Head); // To make the head invisible on the map. The map was having a hissy fit because of hitbox changes. + } + else if (snowRuffianSet) { player.wings = mod.GetEquipSlot("SnowRuffWings", EquipType.Wings); bool falling = player.gravDir == -1 ? player.velocity.Y < 0.05f : player.velocity.Y > 0.05f; @@ -8366,7 +8402,6 @@ namespace CalamityMod.CalPlayer } } }); - public override void ModifyDrawInfo(ref PlayerDrawInfo drawInfo) { if (drawInfo.shadow != 0f) @@ -8606,6 +8641,86 @@ namespace CalamityMod.CalPlayer } }); + public static readonly PlayerLayer IbanDevRobot = new PlayerLayer("CalamityMod", "IbanDevRobot", PlayerLayer.Body, (drawInfo) => + { + Player drawPlayer = drawInfo.drawPlayer; + if (drawPlayer.Calamity().andromedaState == AndromedaPlayerState.Inactive) + return; + Main.playerDrawData.Clear(); + int robot = -1; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && + Main.projectile[i].type == ModContent.ProjectileType() && + Main.projectile[i].owner == drawPlayer.whoAmI) + { + robot = i; + break; + } + } + if (robot == -1) + { + drawPlayer.Calamity().andromedaState = AndromedaPlayerState.Inactive; + return; + } + + GiantIbanRobotOfDoom robotEntityInstance = (GiantIbanRobotOfDoom)Main.projectile[robot].modProjectile; + if (drawPlayer.Calamity().andromedaState == AndromedaPlayerState.SpecialAttack) + { + Texture2D dashTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AndromedaBolt"); + Rectangle frame = dashTexture.Frame(1, 4, 0, robotEntityInstance.RightIconCooldown / 4 % 4); + + DrawData drawData = new DrawData(dashTexture, + drawPlayer.Center + new Vector2(0f, -8f) - Main.screenPosition, + frame, + Color.White, + Main.projectile[robot].rotation, + drawPlayer.Size / 2, + 1f, + Main.projectile[robot].spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, + 1); + drawData.shader = drawPlayer.cBody; + + Main.playerDrawData.Add(drawData); + } + else if (drawPlayer.Calamity().andromedaState == AndromedaPlayerState.LargeRobot) + { + Texture2D robotTexture = ModContent.GetTexture(robotEntityInstance.Texture); + Rectangle frame = new Rectangle(robotEntityInstance.FrameX * robotTexture.Width / 3, robotEntityInstance.FrameY * robotTexture.Height / 7, + robotTexture.Width / 3, robotTexture.Height / 7); + + DrawData drawData = new DrawData(ModContent.GetTexture(Main.projectile[robot].modProjectile.Texture), + Main.projectile[robot].Center + Vector2.UnitY * 6f - Main.screenPosition, + frame, + Color.White, + Main.projectile[robot].rotation, + Main.projectile[robot].Size / 2, + 1f, + Main.projectile[robot].spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, + 1); + drawData.shader = drawPlayer.cBody; + + Main.playerDrawData.Add(drawData); + } + else + { + Texture2D robotTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaSmall"); + Rectangle frame = new Rectangle(0, robotEntityInstance.CurrentFrame * 54, robotTexture.Width, robotTexture.Height / 21); + DrawData drawData = new DrawData(robotTexture, + drawPlayer.Center + new Vector2(0f, -8f) - Main.screenPosition, + frame, + Color.White, + 0f, + drawPlayer.Size / 2, + 1f, + Main.projectile[robot].spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, + 1); + drawData.shader = drawPlayer.cBody; + + Main.playerDrawData.Add(drawData); + } + }); + public override void ModifyDrawLayers(List list) { MiscEffectsBack.visible = true; @@ -8634,6 +8749,7 @@ namespace CalamityMod.CalPlayer } list.Add(ColdDivinityOverlay); list.Add(StratusSphereDrawing); + list.Add(IbanDevRobot); } public PlayerLayer clAfterAll = new PlayerLayer("Calamity", "clAfterAll", PlayerLayer.MiscEffectsFront, delegate (PlayerDrawInfo drawInfo) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index cce27f6054..a18c274a9b 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -315,6 +315,43 @@ namespace CalamityMod.CalPlayer modPlayer.stealthUIAlpha += 0.035f; modPlayer.stealthUIAlpha = MathHelper.Clamp(modPlayer.stealthUIAlpha, 0f, 1f); } + + if (player.Calamity().andromedaState == AndromedaPlayerState.LargeRobot || + player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + player.controlHook = player.releaseHook = false; + } + + if (modPlayer.andromedaCripple > 0) + { + player.velocity = Vector2.Clamp(player.velocity, new Vector2(-11f, -8f), new Vector2(11f, 8f)); + modPlayer.andromedaCripple--; + } + + if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && + player.Calamity().andromedaState != AndromedaPlayerState.Inactive) + { + player.Calamity().andromedaState = AndromedaPlayerState.Inactive; + } + + if (player.Calamity().andromedaState == AndromedaPlayerState.LargeRobot) + { + player.width = 152; + player.height = 212; + player.position.Y -= 170; + } + else if (player.Calamity().andromedaState == AndromedaPlayerState.SpecialAttack) + { + player.width = 24; + player.height = 98; + player.position.Y -= 56; + } + else if (!player.mount.Active) + { + player.width = 20; + player.height = 42; + } + // Proficiency level ups if (CalamityMod.CalamityConfig.ProficiencyEnabled) modPlayer.GetExactLevelUp(); diff --git a/CalamityMod.cs b/CalamityMod.cs index 57d807398e..091630f9c7 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -65,6 +65,7 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.Skies; using CalamityMod.UI; @@ -258,6 +259,8 @@ namespace CalamityMod AddEquipTexture(new SirenBodyAlt(), null, EquipType.Body, "SirenBodyAlt", "CalamityMod/Items/Accessories/SirenTransAlt_Body", "CalamityMod/Items/Accessories/SirenTransAlt_Arms"); AddEquipTexture(new SirenLegsAlt(), null, EquipType.Legs, "SirenLegAlt", "CalamityMod/Items/Accessories/SirenTransAlt_Legs"); + AddEquipTexture(new AndromedaHead(), null, EquipType.Head, "NoHead", "CalamityMod/ExtraTextures/AndromedaWithout_Head"); + AddEquipTexture(new PopoHead(), null, EquipType.Head, "PopoHead", "CalamityMod/Items/Accessories/Vanity/Popo_Head"); AddEquipTexture(new PopoNoselessHead(), null, EquipType.Head, "PopoNoselessHead", "CalamityMod/Items/Accessories/Vanity/PopoNoseless_Head"); AddEquipTexture(new PopoBody(), null, EquipType.Body, "PopoBody", "CalamityMod/Items/Accessories/Vanity/Popo_Body", "CalamityMod/Items/Accessories/Vanity/Popo_Arms"); diff --git a/ExtraTextures/AndromedaBolt.png b/ExtraTextures/AndromedaBolt.png new file mode 100644 index 0000000000..569ef2c846 Binary files /dev/null and b/ExtraTextures/AndromedaBolt.png differ diff --git a/ExtraTextures/AndromedaWithout_Head.png b/ExtraTextures/AndromedaWithout_Head.png new file mode 100644 index 0000000000..92e2245139 Binary files /dev/null and b/ExtraTextures/AndromedaWithout_Head.png differ diff --git a/ExtraTextures/Lasers/AndromedaDeathrayBegin.png b/ExtraTextures/Lasers/AndromedaDeathrayBegin.png new file mode 100644 index 0000000000..85e4add787 Binary files /dev/null and b/ExtraTextures/Lasers/AndromedaDeathrayBegin.png differ diff --git a/ExtraTextures/Lasers/AndromedaDeathrayEnd.png b/ExtraTextures/Lasers/AndromedaDeathrayEnd.png new file mode 100644 index 0000000000..a76189b3b0 Binary files /dev/null and b/ExtraTextures/Lasers/AndromedaDeathrayEnd.png differ diff --git a/ExtraTextures/Lasers/AndromedaDeathrayMid.png b/ExtraTextures/Lasers/AndromedaDeathrayMid.png new file mode 100644 index 0000000000..75611801d5 Binary files /dev/null and b/ExtraTextures/Lasers/AndromedaDeathrayMid.png differ diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 2177191869..56cf495b1c 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -636,6 +636,97 @@ namespace CalamityMod.Items #endregion + #region Andromeda Dev Item Attacks + private bool PerformAndromedaAttacks(Item item, Player player) + { + if (player.whoAmI != Main.myPlayer) + return false; + + int robotIndex = -1; + + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && + Main.projectile[i].type == ModContent.ProjectileType() && + Main.projectile[i].owner == player.whoAmI) + { + robotIndex = i; + break; + } + } + if (robotIndex != -1) + { + Projectile robot = Main.projectile[robotIndex]; + GiantIbanRobotOfDoom robotModProjectile = ((GiantIbanRobotOfDoom)robot.modProjectile); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && + robotModProjectile.TopIconActive && + (robotModProjectile.RightIconCooldown <= GiantIbanRobotOfDoom.RightIconAttackTime || + !robotModProjectile.RightIconActive)) // "Melee" attack + { + int damage = player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot ? GiantIbanRobotOfDoom.RegicideBaseDamageSmall : GiantIbanRobotOfDoom.RegicideBaseDamageLarge; + if (item.Calamity().rogue) + { + damage = (int)(damage * player.RogueDamage()); + } + if (item.melee) + { + damage = (int)(damage * player.MeleeDamage()); + } + if (item.ranged) + { + damage = (int)(damage * player.RangedDamage()); + } + if (item.magic) + { + damage = (int)(damage * player.MagicDamage()); + } + if (item.summon) + { + damage = (int)(damage * player.MinionDamage()); + } + Projectile blade = Projectile.NewProjectileDirect(robot.Center + (robot.spriteDirection > 0).ToDirectionInt() * robot.width / 2 * Vector2.UnitX, + Vector2.Zero, ModContent.ProjectileType(), damage, 15f, player.whoAmI, Projectile.GetByUUID(robot.owner, robot.whoAmI)); + + if (item.Calamity().rogue) + { + blade.Calamity().forceRogue = true; + } + if (item.melee) + { + blade.Calamity().forceMelee = true; + } + if (item.ranged) + { + blade.Calamity().forceRanged = true; + } + if (item.magic) + { + blade.Calamity().forceMagic = true; + } + if (item.summon) + { + blade.Calamity().forceMinion = true; + } + } + + if (!robotModProjectile.TopIconActive && + (robotModProjectile.LeftBracketActive || robotModProjectile.RightBracketActive) && + !robotModProjectile.BottomBracketActive && + robotModProjectile.LaserCooldown <= 0 && + (robotModProjectile.RightIconCooldown <= GiantIbanRobotOfDoom.RightIconAttackTime || + !robotModProjectile.RightIconActive)) // "Ranged" attack + { + robotModProjectile.LaserCooldown = AndromedaDeathRay.TrueTimeLeft * 2; + if (player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot) + { + robotModProjectile.LaserCooldown = AndromedaDeathRay.TrueTimeLeft + 1; + } + } + } + return false; + } + #endregion + #region Use Item Changes public override bool AltFunctionUse(Item item, Player player) @@ -743,6 +834,26 @@ namespace CalamityMod.Items { return false; // Don't use weapons if you're charging with a spear } + + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && + item.fishingPole > 0) + { + return false; + } + + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0 && + item.pick == 0 && item.axe == 0 && item.hammer == 0 && item.autoReuse && (item.Calamity().rogue || item.magic || item.ranged || item.melee)) + { + if (player.altFunctionUse == 0) + { + return PerformAndromedaAttacks(item, player); + } + else + { + return AltFunctionUse(item, player); + } + } + if (modPlayer.profanedCrystalBuffs && item.pick == 0 && item.axe == 0 && item.hammer == 0 && item.autoReuse && (item.Calamity().rogue || item.magic || item.ranged || item.melee)) { if (player.altFunctionUse == 0) @@ -912,6 +1023,21 @@ namespace CalamityMod.Items tt2.overrideColor = new Color(129, 29, 149); if (item.type == ModContent.ItemType()) tt2.overrideColor = new Color(220, 20, 60); + if (item.type == ModContent.ItemType()) + { + if (Main.GlobalTime % 1f < 0.6f) + { + tt2.overrideColor = new Color(89, 229, 255); + } + else if (Main.GlobalTime % 1f < 0.8f) + { + tt2.overrideColor = Color.Lerp(new Color(89, 229, 255), Color.White, (Main.GlobalTime % 1f - 0.6f) / 0.2f); + } + else + { + tt2.overrideColor = Color.Lerp(Color.White, new Color(89, 229, 255), (Main.GlobalTime % 1f - 0.8f) / 0.2f); + } + } // Uniquely colored legendary weapons and Yharim's Crystal if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) diff --git a/Items/Weapons/Summon/PrototypeAndromechaRing.cs b/Items/Weapons/Summon/PrototypeAndromechaRing.cs new file mode 100644 index 0000000000..b1b38912a1 --- /dev/null +++ b/Items/Weapons/Summon/PrototypeAndromechaRing.cs @@ -0,0 +1,93 @@ +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class PrototypeAndromechaRing : ModItem + { + public const int CrippleTime = 360; // 6 seconds + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prototype Andromecha Ring"); + Tooltip.SetDefault("Summons an colossal controllable mech\n" + + "Right click to display the mech's control panel\n" + + "The panel has 3 possible configurations, that you can choose using the brackets on the UI\n" + + "Each bracket powers 2 out of 3 functions, represented by icons on the UI.\n" + + "The bottom left icon shrinks the mech to the size of a player when powered, but weakens its attacks. \n" + + "The bottom right icon charges when powered. At full charge, you can click it to release bursts of branching lightning.\n" + + "The top icon alternates between the 2 the primary attacks when clicked. \n" + + "The primary attack replaces your normal attacks. You can only use the primary attack if the top icon is powered\n" + + "The melee mode slashes enemies with Regicide, an enormous energy blade\n" + + "The ranged mode releases quickly 3 laser beams. Only one laser is shot if the mech is shrunk\n" + + "Exiting the mount while a boss is alive will temporarily hinder your movement\n" + + "The remains of what could have been, forged into a deadly exosuit\n" + + "[c/87ceeb:Now, make them pay.]"); + } + + public override void SetDefaults() + { + item.mana = 200; + item.damage = 9999; + item.useStyle = ItemUseStyleID.HoldingUp; + item.width = item.height = 28; + item.useTime = item.useAnimation = 10; + item.noMelee = true; + item.knockBack = 1f; + item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; + item.Calamity().customRarity = CalamityRarity.ItemSpecific; + item.rare = 10; + item.UseSound = SoundID.Item117; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 100); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.WingsVortex); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + + public override bool CanUseItem(Player player) => !(player.Calamity().andromedaCripple > 0 && CalamityPlayer.areThereAnyDamnBosses); + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + // If the player has any robots, kill them all. + if (player.ownedProjectileCounts[item.shoot] > 0) + { + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && + Main.projectile[i].type == item.shoot && + Main.projectile[i].owner == player.whoAmI) + { + Main.projectile[i].Kill(); + } + } + if (CalamityPlayer.areThereAnyDamnBosses) + { + player.Calamity().andromedaCripple = CrippleTime; + player.AddBuff(ModContent.BuffType(), player.Calamity().andromedaCripple); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AdrenalineBurnout1"), position); + } + return false; + } + // Otherwise create one. + return true; + } + } +} diff --git a/Items/Weapons/Summon/PrototypeAndromechaRing.png b/Items/Weapons/Summon/PrototypeAndromechaRing.png new file mode 100644 index 0000000000..99fecb9b52 Binary files /dev/null and b/Items/Weapons/Summon/PrototypeAndromechaRing.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 048e16585b..a9b76ac438 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -2150,28 +2150,30 @@ namespace CalamityMod.NPCs.SupremeCalamitas DropHelper.DropItem(npc, ModContent.ItemType(), true, essenceMin, essenceMax); // Weapons - // All non-hybrid weapons are listed twice so that the drop rates are actually equal between each unique weapon - DropHelper.DropItemFromSetCondition(npc, Main.expertMode, - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), // Illustrious Knives - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), // Staff of Blushie - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType(), // Voidragon - ModContent.ItemType(), ModContent.ItemType(), - ModContent.ItemType(), ModContent.ItemType() //Temporal Umbrella - ); + + // All non-hybrid weapons are listed twice so that the drop rates are actually equal between each unique weapon + DropHelper.DropItemFromSetCondition(npc, Main.expertMode, + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), // Illustrious Knives + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), // Staff of Blushie + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), // Voidragon + ModContent.ItemType(), ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), //Temporal Umbrella + ModContent.ItemType(), ModContent.ItemType() + ); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge); // Vanity diff --git a/Projectiles/Summon/AndromedaDeathRay.cs b/Projectiles/Summon/AndromedaDeathRay.cs new file mode 100644 index 0000000000..a6b476148f --- /dev/null +++ b/Projectiles/Summon/AndromedaDeathRay.cs @@ -0,0 +1,217 @@ +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.Enums; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class AndromedaDeathRay : ModProjectile + { + // How long this laser can exist before it is deleted. + public const int TrueTimeLeft = 25; + + // Pretty self explanatory + private const float maximumLength = 2000f; + + public float AngularMultiplier = 0f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 18; + projectile.height = 14; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = TrueTimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 4; + } + + // Netcode for sending and receiving shit + // localAI[0] is the timer, localAI[1] is the laser length + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + writer.Write(AngularMultiplier); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + AngularMultiplier = reader.ReadSingle(); + } + + public override void AI() + { + Projectile owner = Main.projectile[(int)projectile.ai[0]]; + Player player = Main.player[projectile.owner]; + + if (owner.type != ModContent.ProjectileType() || !owner.active) + projectile.Kill(); + if (owner.active) + { + projectile.Center = player.Center + new Vector2(owner.spriteDirection == 1 ? 48f : 22f, -28f); + if (player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot) + { + projectile.Center = player.Center + new Vector2(owner.spriteDirection == 1 ? 24f : 2f, 0f); + } + } + + // How fat the laser is + float laserSize = 0.6f + (float)Math.Sin(projectile.localAI[0] / 7f) * 0.025f; // The sine gives a pulsating effect to the laser + + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= TrueTimeLeft) + { + projectile.Kill(); + return; + } + + // Causes the effect where the laser appears to expand/contract at the beginning and end of its life + projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / TrueTimeLeft) * 5f * laserSize; + if (projectile.scale > laserSize) + { + projectile.scale = laserSize; + } + + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + + // Generate dust form the beginning of the ray, giving an illusion of electricity escaping the laser cannon. + if (!Main.dedServ) + { + for (int i = 0; i < 4; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, 133); + dust.velocity = projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(2f, 3.5f) + Main.player[projectile.owner].velocity * 1.5f; + dust.fadeIn = Main.rand.NextFloat(0.6f, 0.85f); + if (player.Calamity().andromedaState == AndromedaPlayerState.SmallRobot) + { + dust.fadeIn = 0.05f; + dust.scale = 0.8f; + } + dust.noGravity = true; + } + } + + Vector2 samplingPoint = projectile.Center; + + float[] samples = new float[3]; + + float determinedLength = 0f; + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, maximumLength, samples); + for (int i = 0; i < samples.Length; i++) + { + determinedLength += samples[i]; + } + determinedLength /= samples.Length; + + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, 0.5f); + Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * projectile.localAI[1]; + // Dust at the end of the beam, if there's a tile there. + if (Collision.SolidCollision(beamEndPosiiton, 16, 16) && !Main.dedServ) + { + if (AngularMultiplier == 0f) + AngularMultiplier = Main.rand.NextFloat(1f, 4f); + float angle = projectile.localAI[0] / 18f; + float x = (float)Math.Sin(angle * AngularMultiplier) * (float)Math.Cos(angle); + float y = (float)Math.Cos(angle * AngularMultiplier) * (float)Math.Sin(angle); + Vector2 velocity = new Vector2(x * 4.5f, y * 2f); + + for (int i = 0; i < 3; i++) + { + Dust dust = Dust.NewDustPerfect(beamEndPosiiton + angle.ToRotationVector2() * 8f, 133); + dust.velocity = velocity.RotatedBy(MathHelper.TwoPi / 3f * i); + dust.scale = (float)Math.Cos(angle) + 1.2f; + dust.noGravity = true; + } + } + + // Draw light blue light across the laser + DelegateMethods.v3_1 = Color.SkyBlue.ToVector3(); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.velocity == Vector2.Zero) + { + return false; + } + Texture2D laserTailTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AndromedaDeathrayBegin"); + Texture2D laserBodyTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AndromedaDeathrayMid"); + Texture2D laserHeadTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AndromedaDeathrayEnd"); + float laserLength = projectile.localAI[1]; + Color drawColor = new Color(1f, 1f, 1f) * 0.9f; + + // Laser tail logic + + Main.spriteBatch.Draw(laserTailTexture, projectile.Center - Main.screenPosition, null, drawColor, projectile.rotation, laserTailTexture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + + // Laser body logic + + laserLength -= (laserTailTexture.Height / 2 + laserHeadTexture.Height) * projectile.scale; + Vector2 centerDelta = projectile.Center; + centerDelta += projectile.velocity * projectile.scale * laserTailTexture.Height / 2f; + if (laserLength > 0f) + { + float laserLengthDelta = 0f; + Rectangle sourceRectangle = new Rectangle(0, 0, laserBodyTexture.Width, laserBodyTexture.Height); + while (laserLengthDelta + 1f < laserLength) + { + if (laserLength - laserLengthDelta < sourceRectangle.Height) + { + sourceRectangle.Height = (int)(laserLength - laserLengthDelta); + } + Main.spriteBatch.Draw(laserBodyTexture, centerDelta - Main.screenPosition, new Rectangle?(sourceRectangle), drawColor, projectile.rotation, new Vector2(sourceRectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + laserLengthDelta += sourceRectangle.Height * projectile.scale; + centerDelta += projectile.velocity * sourceRectangle.Height * projectile.scale; + sourceRectangle.Y += 16; + if (sourceRectangle.Y + sourceRectangle.Height > laserBodyTexture.Height) + { + sourceRectangle.Y = 0; + } + } + } + + // Laser head logic + + Main.spriteBatch.Draw(laserHeadTexture, centerDelta - Main.screenPosition, null, drawColor, projectile.rotation, laserHeadTexture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float value = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref value)) + { + return true; + } + return false; + } + } +} diff --git a/Projectiles/Summon/AndromedaDeathRay.png b/Projectiles/Summon/AndromedaDeathRay.png new file mode 100644 index 0000000000..f3dc2a77b0 Binary files /dev/null and b/Projectiles/Summon/AndromedaDeathRay.png differ diff --git a/Projectiles/Summon/AndromedaRegislash.cs b/Projectiles/Summon/AndromedaRegislash.cs new file mode 100644 index 0000000000..574be30c67 --- /dev/null +++ b/Projectiles/Summon/AndromedaRegislash.cs @@ -0,0 +1,69 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class AndromedaRegislash : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Regislash"); + Main.projFrames[projectile.type] = 6; + } + + public override void SetDefaults() + { + projectile.width = 582; + projectile.height = 304; + projectile.tileCollide = false; + projectile.friendly = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.light = 3f; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 5; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + if (projectile.localAI[0] == 0f) + { + if (CalamityUtils.CountProjectiles(projectile.type) > 1) + { + projectile.Kill(); + return; + } + Main.PlaySound(SoundID.DD2_DrakinShot, projectile.Center); + projectile.rotation = projectile.AngleTo(Main.MouseWorld); + projectile.localAI[0] = 1f; + } + projectile.position = player.Center - projectile.Size / 2f; + if (Math.Abs(Math.Cos(projectile.rotation)) > 0.675f) + { + projectile.position.X += Math.Sign(Math.Cos(projectile.rotation)) * 295f; + } + projectile.position.Y += (float)Math.Sin(projectile.rotation) * 325f; + projectile.frameCounter++; + if (projectile.frameCounter % 7 == 6) + { + projectile.frame++; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.Kill(); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 2); + return false; + } + } +} diff --git a/Projectiles/Summon/AndromedaRegislash.png b/Projectiles/Summon/AndromedaRegislash.png new file mode 100644 index 0000000000..49a0abb62f Binary files /dev/null and b/Projectiles/Summon/AndromedaRegislash.png differ diff --git a/Projectiles/Summon/AndromedaSmall.png b/Projectiles/Summon/AndromedaSmall.png new file mode 100644 index 0000000000..dd64a0897b Binary files /dev/null and b/Projectiles/Summon/AndromedaSmall.png differ diff --git a/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs new file mode 100644 index 0000000000..af57cc96ee --- /dev/null +++ b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.cs @@ -0,0 +1,454 @@ +using CalamityMod.Buffs.Cooldowns; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.IO; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon.AndromedaUI +{ + public class AndromedaUI_Background : ModProjectile + { + public int FadeoutTime = -1; + public Vector2 PlayerOffset = Vector2.Zero; + public static readonly int FadeoutTimeMax = 40; + public static readonly Vector2 LeftBracketOffset = new Vector2(-8f, -6f); + public static readonly Vector2 RightBracketOffset = new Vector2(8f, -6f); + public static readonly Vector2 TopBracketOffset = new Vector2(2f, 27f); + public GiantIbanRobotOfDoom AttachedRobot => (GiantIbanRobotOfDoom)Main.projectile[(int)projectile.localAI[0]].modProjectile; + + // These properties are here to mitigate the need for typing out long and cumbersome slews of the same code to access the robot's variables. + + #region Robot Properties + public bool LeftBracketActive + { + get => AttachedRobot.LeftBracketActive; + set => AttachedRobot.LeftBracketActive = value; + } + public bool RightBracketActive + { + get => AttachedRobot.RightBracketActive; + set => AttachedRobot.RightBracketActive = value; + } + public bool BottomBracketActive + { + get => AttachedRobot.BottomBracketActive; + set => AttachedRobot.BottomBracketActive = value; + } + + public bool LeftIconActive + { + get => AttachedRobot.LeftIconActive; + set => AttachedRobot.LeftIconActive = value; + } + public int RightIconCooldown + { + get => AttachedRobot.RightIconCooldown; + set => AttachedRobot.RightIconCooldown = value; + } + public bool TopIconActive + { + get => AttachedRobot.TopIconActive; + set => AttachedRobot.TopIconActive = value; + } + #endregion + + // Mouse calculations are done primarily in a World context, not Screen, in this file. + Rectangle MouseRectangle => new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 2, 2); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("UI"); + } + + public override void SetDefaults() + { + projectile.width = 62; + projectile.height = 58; + projectile.ignoreWater = true; + projectile.timeLeft = 36000; + projectile.tileCollide = false; + projectile.friendly = true; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(FadeoutTime); + writer.Write(projectile.localAI[0]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + FadeoutTime = reader.ReadInt32(); + projectile.localAI[0] = reader.ReadSingle(); + } + + public override void AI() + { + // Death fade-out effect + if (FadeoutTime > 0) + { + projectile.alpha = (int)MathHelper.Lerp(0f, 255f, 1f - FadeoutTime / (float)FadeoutTimeMax); + FadeoutTime--; + } + else if (FadeoutTime == 0) + { + projectile.Kill(); + } + + // Kill the UI immediately if there is no robot, and halt the AI + if (Main.projectile[(int)projectile.localAI[0]].type != ModContent.ProjectileType() || + !Main.projectile[(int)projectile.localAI[0]].active) + { + projectile.Kill(); + return; + } + + // Fade-in effect + projectile.localAI[1]++; + if (projectile.localAI[1] < 40f) + { + projectile.alpha = (int)MathHelper.Lerp(255f, 0f, projectile.localAI[1] / 40f); + } + + // Adjust the position of the UI. + if (Main.myPlayer == projectile.owner) + { + if (PlayerOffset == Vector2.Zero) + { + PlayerOffset = Main.player[projectile.owner].Center - projectile.Center; + } + projectile.Center = Main.player[projectile.owner].Center - PlayerOffset; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + // Should be invisible for players that do not control the UI + if (Main.myPlayer == projectile.owner) + { + // Draw the background UI + spriteBatch.Draw(ModContent.GetTexture(Texture), + projectile.Center - Main.screenPosition, + null, + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + DrawBrackets(spriteBatch); + DrawIcons(spriteBatch); + + + // Kills the projectile if the player clicks something that isn't the UI. + // This is done in here and not AI to ensure that the above checks are done immediately before this check. + if (!Main.blockMouse && Main.mouseLeft && FadeoutTime == -1) + { + FadeoutTime = FadeoutTimeMax; + } + } + + return false; + } + + public void DrawBrackets(SpriteBatch spriteBatch) + { + Texture2D leftBracketTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/LeftBracket" + (LeftBracketActive ? "Lit" : "")); + Texture2D leftBracketTextureHovered = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/LeftBracketHovered"); + + Texture2D rightBracketTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/RightBracket" + (RightBracketActive ? "Lit" : "")); + Texture2D rightBracketTextureHovered = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/RightBracketHovered"); + + Texture2D topBracketTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/TopBracket" + (BottomBracketActive ? "Lit" : "")); + Texture2D topBracketTextureHovered = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/TopBracketHovered"); + + // Top bracket + Vector2 topBracketPosition = projectile.Bottom + TopBracketOffset; + Rectangle topBracketFrame = new Rectangle((int)topBracketPosition.X - topBracketTexture.Width / 2, + (int)topBracketPosition.Y - 24, + topBracketTexture.Width - 18, topBracketTexture.Height - 12); + bool topBracketSelect = MouseRectangle.Intersects(topBracketFrame) && !BottomBracketActive; + + spriteBatch.Draw(topBracketSelect ? topBracketTextureHovered : topBracketTexture, + topBracketPosition - Main.screenPosition, + null, + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + + // Left bracket + Vector2 leftBracketPosition = projectile.Center + LeftBracketOffset; + Rectangle leftBracketFrame = new Rectangle((int)leftBracketPosition.X - leftBracketTexture.Width / 2, + (int)leftBracketPosition.Y - 24, + leftBracketTexture.Width - 12, leftBracketTexture.Height - 18); + bool leftBracketSelect = MouseRectangle.Intersects(leftBracketFrame) && !LeftBracketActive; + + spriteBatch.Draw(leftBracketSelect ? leftBracketTextureHovered : leftBracketTexture, + leftBracketPosition - Main.screenPosition, + null, + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + + // Right bracket + Vector2 rightBracketPosition = projectile.Center + RightBracketOffset + (projectile.width / 2 - 1) * Vector2.UnitX; + Rectangle rightBracketFrame = new Rectangle((int)rightBracketPosition.X - rightBracketTexture.Width / 2, + (int)rightBracketPosition.Y - 24, + rightBracketTexture.Width - 12, rightBracketTexture.Height - 18); + bool rightBracketSelect = MouseRectangle.Intersects(rightBracketFrame) && !RightBracketActive; + + spriteBatch.Draw(rightBracketSelect ? rightBracketTextureHovered : rightBracketTexture, + rightBracketPosition - Main.screenPosition, + null, + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + + if (leftBracketSelect || rightBracketSelect || topBracketSelect) + { + Main.blockMouse = true; + if (Main.mouseLeft && Main.projectile[(int)projectile.localAI[0]].ai[0] <= 0f) + { + if (leftBracketSelect) + { + LeftBracketActive = true; + RightBracketActive = BottomBracketActive = false; + } + if (rightBracketSelect) + { + RightBracketActive = true; + LeftBracketActive = BottomBracketActive = false; + LeftIconActive = false; + } + if (topBracketSelect) + { + BottomBracketActive = true; + LeftBracketActive = RightBracketActive = false; + TopIconActive = false; + } + Main.projectile[(int)projectile.localAI[0]].ai[0] = 30f; + } + } + } + + public void DrawIcons(SpriteBatch spriteBatch) + { + // Left Icon (Big/Small indicator) + DrawLeftIcon(spriteBatch); + + // Right Icon (Lightning charge + cooldown) + DrawRightIcon(spriteBatch); + + // Top Icon (Alternating between melee swing and ranged bursts) + DrawTopIcon(spriteBatch); + } + + public void DrawLeftIcon(SpriteBatch spriteBatch) + { + // Define icons to draw + Texture2D smallIndicator = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/SmallIcon"); + Texture2D smallIndicatorLocked = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/Lock"); + Texture2D textureToDraw = smallIndicator; + + // An offset is required for said icons, as they have difference sizes. Don't touch them unless the sprites are modified. + // Bless whoever is tasked's soul if they are indeed changed + Vector2 iconOffset = new Vector2(2f, 28f); + Vector2 drawPosition = projectile.Center + iconOffset; + + bool eitherBracketActive = LeftBracketActive || BottomBracketActive; + + // Lock the icon if the active bracket does not activate the icon + if (!eitherBracketActive || RightBracketActive) + { + textureToDraw = smallIndicatorLocked; + iconOffset = new Vector2(7f, 30f); + drawPosition = projectile.Center + iconOffset; + } + bool wasActive = LeftIconActive; + LeftIconActive = textureToDraw == smallIndicator; // In simpler terms, LeftIconActive = Whether the robot is small vs if it's big. + // If the player's robot state changed, make a scene + if (LeftIconActive != wasActive) + { + if (!Main.dedServ) + { + Player player = Main.player[projectile.owner]; + for (int i = 0; i < 45; i++) + { + Dust dust = Dust.NewDustPerfect(player.Center + Utils.NextVector2Circular(Main.rand, 60f, 90f), 26); + dust.velocity = Utils.NextVector2Circular(Main.rand, 4f, 4f); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 1.35f); + } + for (int i = 0; i < 4; i++) + { + Utils.PoofOfSmoke(player.Center + Utils.NextVector2Circular(Main.rand, 20f, 30f)); + } + } + } + // And finally draw + spriteBatch.Draw(textureToDraw, + drawPosition - Main.screenPosition, + null, + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + } + + public void DrawRightIcon(SpriteBatch spriteBatch) + { + // Define icons to draw + Texture2D thunderIndicator = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/ThunderIcon"); + Texture2D thunderIndicatorHovered = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/ThunderIconHovered"); + Texture2D thunderIndicatorCharge = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/ThunderIconCharge"); + Texture2D thunderIndicatorLocked = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/Lock"); + Texture2D textureToDraw = thunderIndicatorLocked; + + // An offset is required for said icons, as they have difference sizes. Don't touch them unless the sprites are modified. + // Bless whoever is tasked's soul if they are indeed changed + Vector2 iconOffset = new Vector2(40f, 32f); + Vector2 drawPosition; + + bool eitherBracketActive = RightBracketActive || BottomBracketActive; + + // Lock the icon if the active bracket does not activate the icon + if (eitherBracketActive && !LeftBracketActive) + { + textureToDraw = thunderIndicator; + } + + if (textureToDraw == thunderIndicatorLocked) + { + iconOffset = new Vector2(36f, 30f); + } + + drawPosition = projectile.Center + iconOffset; + + // Otherwise do mouse click/hover checks, and, assuming the cooldown is at 0, perform the special attack and restart the cooldown. + if (textureToDraw != thunderIndicatorLocked && RightIconCooldown <= 0) + { + Rectangle iconFrame = new Rectangle((int)drawPosition.X - 36, + (int)drawPosition.Y - 32, + textureToDraw.Width + 4, textureToDraw.Height + 6); + textureToDraw = thunderIndicator; + if (MouseRectangle.Intersects(iconFrame)) + { + textureToDraw = thunderIndicatorHovered; + // Prevent clicking affecting other things. For example, disallow weapon firing. + Main.blockMouse = true; + if (Main.mouseLeft && Main.projectile[(int)projectile.localAI[0]].ai[0] <= 0f) + { + FadeoutTime = FadeoutTimeMax; + RightIconCooldown = GiantIbanRobotOfDoom.RightIconCooldownMax; + // A cooldown value. This ensures that the game will not register another click + // one frame after the first one. + Main.projectile[(int)projectile.localAI[0]].ai[0] = 30f; + + // Explosion effect + if (!Main.dedServ) + { + for (int i = 0; i < 80; i++) + { + Dust dust = Dust.NewDustPerfect(Main.projectile[(int)projectile.localAI[0]].Center, Utils.SelectRandom(Main.rand, 226, 263)); + dust.velocity = Main.rand.NextVector2Circular(14f, 14f); + dust.fadeIn = 1.1f; + dust.noGravity = true; + } + } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeMechGaussRifle"), projectile.Center); + } + } + } + // And finally draw the cooldown texture + the icon + float chargeCompletionRatio = 1f - (RightIconCooldown / (float)GiantIbanRobotOfDoom.RightIconCooldownMax); + spriteBatch.Draw(thunderIndicatorCharge, + projectile.Center + new Vector2(34f, 30f) - Main.screenPosition, + new Rectangle(0, 0, thunderIndicatorCharge.Width, (int)(chargeCompletionRatio * thunderIndicatorCharge.Height)), // Fill up vertically + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + spriteBatch.Draw(textureToDraw, + drawPosition - Main.screenPosition, + null, + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 1f); + } + + public void DrawTopIcon(SpriteBatch spriteBatch) + { + // Define icons to draw + Texture2D meleeIndicator = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/MeleeIcon"); + Texture2D rangedIndicator = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/RangedIcon"); + Texture2D attackIndicatorLocked = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/Lock"); + Texture2D meleeIndicatorHovered = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/MeleeIconHovered"); + Texture2D rangedIndicatorHovered = ModContent.GetTexture("CalamityMod/Projectiles/Summon/AndromedaUI/RangedIconHovered"); + Texture2D textureToDraw = TopIconActive ? meleeIndicator : rangedIndicator; + + // An offset is required for said icons, as they have difference sizes. Don't touch them unless the sprites are modified. + // Bless whoever is tasked's soul if they are indeed changed + Vector2 iconOffset = new Vector2(22f, 8f); + Vector2 drawPosition = projectile.Center + iconOffset; + + bool eitherBracketActive = LeftBracketActive || RightBracketActive; + + // Lock the icon if the active bracket does not activate the icon + if (!eitherBracketActive || BottomBracketActive) + { + textureToDraw = attackIndicatorLocked; + iconOffset = new Vector2(22f, 6f); + drawPosition = projectile.Center + iconOffset; + } + // Otherwise do mouse click/hover checks, and, assuming the cooldown is at 0, perform the special attack and restart the cooldown. + else if (eitherBracketActive) + { + Rectangle iconFrame = new Rectangle((int)drawPosition.X - 36, + (int)drawPosition.Y - 32, + textureToDraw.Width, textureToDraw.Height); + if (MouseRectangle.Intersects(iconFrame)) + { + textureToDraw = TopIconActive ? meleeIndicatorHovered : rangedIndicatorHovered; + // Prevent clicking affecting other things. For example, disallow weapon firing. + Main.blockMouse = true; + if (Main.mouseLeft && Main.projectile[(int)projectile.localAI[0]].ai[0] <= 0f) + { + TopIconActive = !TopIconActive; + // A cooldown value. This ensures that the game will not register another click + // one frame after the first one. + Main.projectile[(int)projectile.localAI[0]].ai[0] = 30f; + } + } + } + // And finally draw + spriteBatch.Draw(textureToDraw, + drawPosition - Main.screenPosition, + null, + Color.White * projectile.Opacity, + 0f, + projectile.Size * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + } + + public override bool CanDamage() => false; // This is a UI. It should not do damage. + } +} diff --git a/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.png b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.png new file mode 100644 index 0000000000..92c8789814 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/AndromedaUI_Background.png differ diff --git a/Projectiles/Summon/AndromedaUI/BigIcon.png b/Projectiles/Summon/AndromedaUI/BigIcon.png new file mode 100644 index 0000000000..bb7a624f34 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/BigIcon.png differ diff --git a/Projectiles/Summon/AndromedaUI/BigIconHovered.png b/Projectiles/Summon/AndromedaUI/BigIconHovered.png new file mode 100644 index 0000000000..b27b0dc63d Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/BigIconHovered.png differ diff --git a/Projectiles/Summon/AndromedaUI/LeftBracket.png b/Projectiles/Summon/AndromedaUI/LeftBracket.png new file mode 100644 index 0000000000..6525d99282 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/LeftBracket.png differ diff --git a/Projectiles/Summon/AndromedaUI/LeftBracketHovered.png b/Projectiles/Summon/AndromedaUI/LeftBracketHovered.png new file mode 100644 index 0000000000..ea4d3a9ded Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/LeftBracketHovered.png differ diff --git a/Projectiles/Summon/AndromedaUI/LeftBracketLit.png b/Projectiles/Summon/AndromedaUI/LeftBracketLit.png new file mode 100644 index 0000000000..64114b3116 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/LeftBracketLit.png differ diff --git a/Projectiles/Summon/AndromedaUI/Lock.png b/Projectiles/Summon/AndromedaUI/Lock.png new file mode 100644 index 0000000000..4679b899c6 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/Lock.png differ diff --git a/Projectiles/Summon/AndromedaUI/MeleeIcon.png b/Projectiles/Summon/AndromedaUI/MeleeIcon.png new file mode 100644 index 0000000000..e715487add Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/MeleeIcon.png differ diff --git a/Projectiles/Summon/AndromedaUI/MeleeIconHovered.png b/Projectiles/Summon/AndromedaUI/MeleeIconHovered.png new file mode 100644 index 0000000000..65cc24e115 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/MeleeIconHovered.png differ diff --git a/Projectiles/Summon/AndromedaUI/RangedIcon.png b/Projectiles/Summon/AndromedaUI/RangedIcon.png new file mode 100644 index 0000000000..2ce174b9ae Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/RangedIcon.png differ diff --git a/Projectiles/Summon/AndromedaUI/RangedIconHovered.png b/Projectiles/Summon/AndromedaUI/RangedIconHovered.png new file mode 100644 index 0000000000..d20d09fdf4 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/RangedIconHovered.png differ diff --git a/Projectiles/Summon/AndromedaUI/RightBracket.png b/Projectiles/Summon/AndromedaUI/RightBracket.png new file mode 100644 index 0000000000..4a13be7270 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/RightBracket.png differ diff --git a/Projectiles/Summon/AndromedaUI/RightBracketHovered.png b/Projectiles/Summon/AndromedaUI/RightBracketHovered.png new file mode 100644 index 0000000000..f89604028f Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/RightBracketHovered.png differ diff --git a/Projectiles/Summon/AndromedaUI/RightBracketLit.png b/Projectiles/Summon/AndromedaUI/RightBracketLit.png new file mode 100644 index 0000000000..b22ff3f486 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/RightBracketLit.png differ diff --git a/Projectiles/Summon/AndromedaUI/SmallIcon.png b/Projectiles/Summon/AndromedaUI/SmallIcon.png new file mode 100644 index 0000000000..a9672734f3 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/SmallIcon.png differ diff --git a/Projectiles/Summon/AndromedaUI/ThunderIcon.png b/Projectiles/Summon/AndromedaUI/ThunderIcon.png new file mode 100644 index 0000000000..758a32592d Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/ThunderIcon.png differ diff --git a/Projectiles/Summon/AndromedaUI/ThunderIconCharge.png b/Projectiles/Summon/AndromedaUI/ThunderIconCharge.png new file mode 100644 index 0000000000..428b8f49b9 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/ThunderIconCharge.png differ diff --git a/Projectiles/Summon/AndromedaUI/ThunderIconHovered.png b/Projectiles/Summon/AndromedaUI/ThunderIconHovered.png new file mode 100644 index 0000000000..12947e6125 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/ThunderIconHovered.png differ diff --git a/Projectiles/Summon/AndromedaUI/TopBracket.png b/Projectiles/Summon/AndromedaUI/TopBracket.png new file mode 100644 index 0000000000..de4204d139 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/TopBracket.png differ diff --git a/Projectiles/Summon/AndromedaUI/TopBracketHovered.png b/Projectiles/Summon/AndromedaUI/TopBracketHovered.png new file mode 100644 index 0000000000..481d2b7ca3 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/TopBracketHovered.png differ diff --git a/Projectiles/Summon/AndromedaUI/TopBracketLit.png b/Projectiles/Summon/AndromedaUI/TopBracketLit.png new file mode 100644 index 0000000000..e9ebbb3eb6 Binary files /dev/null and b/Projectiles/Summon/AndromedaUI/TopBracketLit.png differ diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs new file mode 100644 index 0000000000..024a04af96 --- /dev/null +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -0,0 +1,487 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Buffs.Mounts; +using CalamityMod.Items; +using CalamityMod.Projectiles.Summon.AndromedaUI; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent.Events; +using Terraria.ID; +using Terraria.ModLoader; +using System; +using System.Collections.Generic; +using CalamityMod.Buffs.Cooldowns; + +namespace CalamityMod.Projectiles.Summon +{ + public class AndromedaHead : EquipTexture + { + public override bool DrawHead() => false; + } + public class GiantIbanRobotOfDoom : ModProjectile + { + public int FrameX = 0; + public int FrameY = 0; + public int CurrentFrame + { + get => FrameY + FrameX * 7; + set + { + FrameX = value / 7; + FrameY = value % 7; + } + } + public bool LeftBracketActive = false; + public bool RightBracketActive = true; // This is supposed to be the default bracket, according to Iban. Ask him before changing this. + public bool BottomBracketActive = false; + public bool RightIconActive => RightBracketActive || BottomBracketActive; + + public bool LeftIconActive = false; + public bool TopIconActive = false; + + public int RightIconCooldown = 0; + public const int RightIconAttackTime = 480; // 8 second wait + public const int RightIconCooldownMax = RightIconAttackTime * 2; // 16 second wait. + public const float RightIconLungeSpeed = 28f; + + /// + /// This cooldown is set in + /// + public int LaserCooldown = 0; + public static Vector2 LightningShootOffset; + public const int SpecialLightningBaseDamage = 5600; + public const int RegicideBaseDamageSmall = 12650; + public const int RegicideBaseDamageLarge = 17800; + public const int LaserBaseDamage = 21000; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Andromeda"); + ProjectileID.Sets.NeedsUUID[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 152; + projectile.height = 212; + projectile.netImportant = true; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.timeLeft = 18000; + projectile.timeLeft *= 5; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.Calamity().rogue = true; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 11; + } + public override void AI() + { + Player player = Main.player[projectile.owner]; + InitializeValues(player); + HandleCooldowns(player); + ManipulatePlayerValues(player); + RegisterRightClick(player); + SetFrames(player); + SetSpriteDirection(player); + player.AddBuff(LeftIconActive ? ModContent.BuffType() : ModContent.BuffType(), 2); + } + public void InitializeValues(Player player) + { + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.localAI[0] = 1f; + } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = trueDamage; + } + } + public void HandleCooldowns(Player player) + { + if (RightIconCooldown > 0 && RightIconActive) + { + RightIconCooldown--; // The shooting of the lightning is done in the SetFrames method. + } + if (LaserCooldown > 0) + { + LaserCooldown--; + LaserBeam(player); + } + } + public void ManipulatePlayerValues(Player player) + { + if (!player.active || player.dead) + { + player.Calamity().andromedaState = AndromedaPlayerState.Inactive; + projectile.Kill(); + return; + } + projectile.Center = player.Center + Vector2.UnitY * (6f + player.gfxOffY); + player.Calamity().andromedaState = LeftIconActive ? AndromedaPlayerState.SmallRobot : AndromedaPlayerState.LargeRobot; + player.channel = false; + if (RightIconCooldown > RightIconAttackTime) + { + player.Calamity().andromedaState = AndromedaPlayerState.SpecialAttack; + + for (int i = 0; i < 4; i++) + { + Vector2 spinningPoint = new Vector2(0f, -28f).RotatedBy(RightIconCooldown / 60f * MathHelper.TwoPi) + .RotatedBy(projectile.velocity.ToRotation()) + .RotatedBy(MathHelper.Lerp(MathHelper.ToRadians(-40f), MathHelper.ToRadians(40f), i / 4f)); + + Vector2 center = player.Center + new Vector2(6f, -2f).RotatedBy(player.velocity.ToRotation()); + + int idx = Dust.NewDust(center, 0, 0, 226, 0f, 0f, 100, default, 0.5f); + Main.dust[idx].noGravity = true; + Main.dust[idx].position = center + spinningPoint; + Main.dust[idx].velocity = Vector2.Zero; + spinningPoint *= -1f; + + idx = Dust.NewDust(center, 0, 0, 226, 0f, 0f, 100, default, 0.5f); + Main.dust[idx].noGravity = true; + Main.dust[idx].position = center + spinningPoint; + Main.dust[idx].velocity = Vector2.Zero; + } + // Exit the charge mode early. + if ((player.velocity.X == 0f || player.velocity.Y == 0f) && RightIconCooldown < RightIconCooldownMax - 30f) + { + ExitChargeModeEarly(player); + } + player.velocity = Vector2.Lerp(player.velocity, projectile.DirectionTo(Main.MouseWorld) * RightIconLungeSpeed, 0.225f); + projectile.rotation = player.velocity.ToRotation() + MathHelper.PiOver2; + } + else projectile.rotation = 0f; + if (player.mount != null) // Kill any mounts + { + player.mount.Dismount(player); + } + } + public void RegisterRightClick(Player player) + { + if (Main.mouseRight && projectile.ai[0] <= 0f) + { + projectile.ai[0] = 30f; + // Exit the charge mode early. + if (RightIconCooldown > RightIconAttackTime) + { + ExitChargeModeEarly(player); + return; + } + // If the player has any existing UIs, kill them all. + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && + Main.projectile[i].type == ModContent.ProjectileType() && + Main.projectile[i].owner == player.whoAmI) + { + Main.projectile[i].Kill(); + } + } + } + // Otherwise, create one. + else + { + if (Main.myPlayer == player.whoAmI) + { + Projectile ui = Projectile.NewProjectileDirect(Main.MouseWorld, + Vector2.Zero, + ModContent.ProjectileType(), + 0, + 0f, + player.whoAmI); + ui.localAI[0] = Projectile.GetByUUID(projectile.owner, projectile.whoAmI); + ui.netUpdate = true; + } + } + } + else if (projectile.ai[0] > 0f) + { + projectile.ai[0]--; + } + } + public void SetFrames(Player player) + { + projectile.frameCounter++; + if (RightIconCooldown <= RightIconAttackTime) + { + if (Math.Abs(player.velocity.Y) != 0f) + { + SetFlyingFrames(player); + } + else if (Math.Abs(player.velocity.X) > 3f) + { + SetWalkingFrames(); + } + if (player.velocity == Vector2.Zero) + { + CurrentFrame = 0; + } + } + } + public void SetFlyingFrames(Player player) + { + // Falling + if (player.velocity.Y > 0f) + { + CurrentFrame = 1; + return; + } + // Quickly go to flying frames + if (CurrentFrame == 0) + { + if (projectile.frameCounter >= 4) + { + CurrentFrame++; + projectile.frameCounter = 0; + } + } + // Flying frames + else if (projectile.frameCounter % 4 == 3) + { + CurrentFrame++; + if (CurrentFrame >= 6) + CurrentFrame = 2; + } + + // Dust effect + + Vector2 dustOffset = new Vector2(94f, 58f); + if (projectile.spriteDirection == -1) + { + dustOffset.X = 214 - dustOffset.X; + } + if (!Main.dedServ && player.Calamity().andromedaState == AndromedaPlayerState.LargeRobot) + { + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.position + dustOffset, 263); + dust.velocity = Vector2.Normalize(dust.position - projectile.Top).RotatedByRandom(0.4f) * Main.rand.NextFloat(4f, 7f) + projectile.velocity; + dust.color = Color.SkyBlue; + dust.scale = Main.rand.NextFloat(0.9f, 1.35f); + dust.noGravity = true; + } + } + + // Clamp frames + if (CurrentFrame >= 6) + CurrentFrame = 0; + } + public void SetWalkingFrames() + { + Player player = Main.player[projectile.owner]; + int walkInterval = (int)MathHelper.Clamp(8 - Math.Abs(player.velocity.X) / 3.5f, 1, 8); + if (player.velocity.X == 0f) + { + CurrentFrame = 0; + } + else if (projectile.frameCounter >= walkInterval) + { + projectile.frameCounter = 0; + CurrentFrame++; + if (CurrentFrame >= 13) + { + CurrentFrame = 6; + } + } + // Clamp frames + if (CurrentFrame >= 14 || CurrentFrame <= 6) + CurrentFrame = 6; + } + public void SetSpriteDirection(Player player) + { + if (RightIconCooldown > RightIconAttackTime) + { + projectile.spriteDirection = (Math.Cos(projectile.rotation) > 0).ToDirectionInt(); + return; + } + if (player.velocity.X != 0) // So that the original sprite direction is maintained when there is no X movement. + { + projectile.spriteDirection = (player.velocity.X > 0).ToDirectionInt(); + } + int slashIndex = -1; + + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && + Main.projectile[i].type == ModContent.ProjectileType() && + Main.projectile[i].owner == projectile.owner) + { + slashIndex = i; + break; + } + } + + if (slashIndex != -1) + { + if (Main.projectile[slashIndex].frameCounter > 0) // To ensure that the starting variables of the blade have been initialized + { + projectile.spriteDirection = (Math.Cos(Main.projectile[slashIndex].rotation) > 0).ToDirectionInt(); // ai[1] is the blade's starting rotation + } + } + + int laserBeamIndex = -1; + + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && + Main.projectile[i].type == ModContent.ProjectileType() && + Main.projectile[i].owner == projectile.owner) + { + laserBeamIndex = i; + break; + } + } + + if (laserBeamIndex != -1) + { + projectile.spriteDirection = (Math.Cos(Main.projectile[laserBeamIndex].velocity.ToRotation()) > 0).ToDirectionInt(); // ai[1] is the blade's starting rotation + } + } + public void LaserBeam(Player player) + { + if (LaserCooldown % (AndromedaDeathRay.TrueTimeLeft - 10) == (AndromedaDeathRay.TrueTimeLeft - 11)) + { + if (projectile.owner == Main.myPlayer) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeMechGaussRifle"), projectile.Center); + int damage = LaserBaseDamage; + if (player.HeldItem != null) + { + if (player.HeldItem.magic) + { + damage = (int)(damage * player.MagicDamage()); + } + else if (player.HeldItem.melee) + { + damage = (int)(damage * player.MeleeDamage()); + } + else if (player.HeldItem.ranged) + { + damage = (int)(damage * player.RangedDamage()); + } + else if (player.HeldItem.summon) + { + damage = (int)(damage * player.MinionDamage()); + } + else if (player.HeldItem.Calamity().rogue) + { + damage = (int)(damage * player.RogueDamage()); + } + else + { + damage = (int)(damage * player.AverageDamage()); + } + } + Vector2 laserVelocity = (Main.MouseWorld - (Main.player[projectile.owner].Center + new Vector2(projectile.spriteDirection == 1 ? 48f : 22f, -28f))).SafeNormalize(Vector2.UnitX * projectile.spriteDirection); + Projectile deathLaser = Projectile.NewProjectileDirect(projectile.Center, + laserVelocity, + ModContent.ProjectileType(), + damage, + 8f, + projectile.owner, + projectile.whoAmI); + if (player.HeldItem != null) + { + if (player.HeldItem.magic) + { + deathLaser.Calamity().forceMagic = true; + } + else if (player.HeldItem.melee) + { + deathLaser.Calamity().forceMelee = true; + } + else if (player.HeldItem.ranged) + { + deathLaser.Calamity().forceRanged = true; + } + else if (player.HeldItem.summon) + { + deathLaser.Calamity().forceMinion = true; + } + else if (player.HeldItem.Calamity().rogue) + { + deathLaser.Calamity().forceRogue = true; + } + else + { + deathLaser.Calamity().forceTypeless = true; + } + } + } + } + } + public void ExitChargeModeEarly(Player player) + { + RightIconCooldown = RightIconAttackTime; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeMechGaussRifle"), projectile.Center); + SpecialAttackExplosionDust(player); + } + public void SpecialAttackExplosionDust(Player player) + { + if (!Main.dedServ) + { + // Petal + for (int angleInterval = 0; angleInterval < 10; angleInterval++) + { + for (int outwardness = 190; outwardness < 360; outwardness += 8) + { + for (int speedSign = -1; speedSign <= 1; speedSign += 2) + { + float angle = MathHelper.Lerp(0f, MathHelper.TwoPi / 10f, (outwardness - 190f) / 170f); + Dust dust = Dust.NewDustPerfect(projectile.Center, 221); + dust.noGravity = true; + dust.scale = 1.6f; + dust.position = player.Center + outwardness * (MathHelper.TwoPi / 10f * angleInterval).ToRotationVector2().RotatedBy(angle); + dust.velocity = player.DirectionTo(dust.position) * 8f * speedSign; + + dust = Dust.NewDustPerfect(projectile.Center, 221); + dust.noGravity = true; + dust.scale = 1.6f; + dust.position = player.Center + outwardness * (MathHelper.TwoPi / 10f * angleInterval).ToRotationVector2().RotatedBy(-angle); + dust.velocity = player.DirectionTo(dust.position) * 8f * speedSign; + } + } + } + // Star + int pointsOnStar = 6; + for (int k = 0; k < 2; k++) + { + for (int i = 0; i < pointsOnStar; i++) + { + float angle = MathHelper.Pi * 1.5f - i * MathHelper.TwoPi / pointsOnStar; + float nextAngle = MathHelper.Pi * 1.5f - ((i + 3) % pointsOnStar) * MathHelper.TwoPi / pointsOnStar; + if (k == 1) + nextAngle = MathHelper.Pi * 1.5f - (i + 2) * MathHelper.TwoPi / pointsOnStar; + Vector2 start = angle.ToRotationVector2(); + Vector2 end = nextAngle.ToRotationVector2(); + int pointsOnStarSegment = 24; + for (int j = 0; j < pointsOnStarSegment; j++) + { + Dust dust = Dust.NewDustPerfect(player.Center, 221); + dust.noGravity = true; + dust.scale = 1.9f; + dust.velocity = Vector2.Lerp(start, end, j / (float)pointsOnStarSegment) * 13f * new Vector2(1.414f, 1f); + } + } + } + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) => false; // Drawing is done completely by the player. + public override bool OnTileCollide(Vector2 oldVelocity) => false; + public override bool CanDamage() => false; + public override void Kill(int timeLeft) + { + Player player = Main.player[projectile.owner]; + player.width = 20; + player.height = 42; + } + } +} diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.png b/Projectiles/Summon/GiantIbanRobotOfDoom.png new file mode 100644 index 0000000000..a8d08b1be8 Binary files /dev/null and b/Projectiles/Summon/GiantIbanRobotOfDoom.png differ