diff --git a/Buffs/Mounts/DraedonGamerChairBuff.cs b/Buffs/Mounts/DraedonGamerChairBuff.cs new file mode 100644 index 0000000000..db7f56cb59 --- /dev/null +++ b/Buffs/Mounts/DraedonGamerChairBuff.cs @@ -0,0 +1,24 @@ +using CalamityMod.Items.Mounts; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Mounts +{ + public class DraedonGamerChairBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Exo Chair"); + Description.SetDefault("Riding a physics defying gamer chair"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.mount.SetMount(ModContent.MountType(), player); + player.buffTime[buffIndex] = 10; + player.Calamity().ExoChair = true; + } + } +} diff --git a/Buffs/Mounts/DraedonGamerChairBuff.png b/Buffs/Mounts/DraedonGamerChairBuff.png new file mode 100644 index 0000000000..9c3a83ed68 Binary files /dev/null and b/Buffs/Mounts/DraedonGamerChairBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 31787d6ac0..cf0e7cfefa 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -327,6 +327,7 @@ namespace CalamityMod.CalPlayer public bool angryDog = false; public bool fab = false; public bool crysthamyr = false; + public bool ExoChair = false; public AndromedaPlayerState andromedaState; public int andromedaCripple; public const float UnicornSpeedNerfPower = 0.8f; @@ -1530,6 +1531,7 @@ namespace CalamityMod.CalPlayer angryDog = false; fab = false; crysthamyr = false; + ExoChair = false; miniOldDuke = false; abyssalDivingSuitPlates = false; @@ -2297,6 +2299,7 @@ namespace CalamityMod.CalPlayer angryDog = false; fab = false; crysthamyr = false; + ExoChair = false; abyssalDivingSuitPlates = false; sirenWaterBuff = false; sirenIce = false; @@ -3937,6 +3940,47 @@ namespace CalamityMod.CalPlayer } #endregion + #region PreUpdateMovement + public override void PreUpdateMovement() + { + // Remove acceleration when using the exo chair. + if (ExoChair) + { + float speed = DraedonGamerChairMount.MovementSpeed; + if (CalamityMod.ExoChairSpeedupHotkey.Current) + speed *= 2f; + + if (player.controlLeft) + { + player.velocity.X = -speed; + player.direction = -1; + } + else if (player.controlRight) + { + player.velocity.X = speed; + player.direction = 1; + } + else + player.velocity.X = 0f; + + if (player.controlUp) + player.velocity.Y = -speed; + + else if (player.controlDown) + { + player.velocity.Y = speed; + if (Collision.TileCollision(player.position, player.velocity, player.width, player.height, true, false, (int)player.gravDir).Y == 0f) + player.velocity.Y = 0.5f; + } + else + player.velocity.Y = 0f; + + if (player.controlJump) + player.velocity *= 0.5f; + } + } + #endregion + #region PostUpdateBuffs public override void PostUpdateBuffs() => ForceVariousEffects(); #endregion diff --git a/CalamityMod.cs b/CalamityMod.cs index 6d6cfe1a51..b7bff76bd1 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -84,6 +84,7 @@ namespace CalamityMod public static ModHotKey PlaguePackHotKey; public static ModHotKey AngelicAllianceHotKey; public static ModHotKey GodSlayerDashHotKey; + public static ModHotKey ExoChairSpeedupHotkey; // Boss Spawners public static int ghostKillCount = 0; @@ -182,8 +183,9 @@ namespace CalamityMod PlaguePackHotKey = RegisterHotKey("Booster Dash", "Q"); AngelicAllianceHotKey = RegisterHotKey("Angelic Alliance Blessing", "G"); GodSlayerDashHotKey = RegisterHotKey("God Slayer Dash", "H"); + ExoChairSpeedupHotkey = RegisterHotKey("Exo Chair Speed Up", "LeftShift"); - if (!Main.dedServ) + if (!Main.dedServ) LoadClient(); ILChanges.Load(); diff --git a/Items/Mounts/DraedonGamerChairMount.cs b/Items/Mounts/DraedonGamerChairMount.cs new file mode 100644 index 0000000000..bae00c4bad --- /dev/null +++ b/Items/Mounts/DraedonGamerChairMount.cs @@ -0,0 +1,77 @@ +using CalamityMod.Buffs.Mounts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Mounts +{ + public class DraedonGamerChairMount : ModMountData + { + public const float MovementSpeed = 12f; + public override void SetDefaults() + { + mountData.spawnDust = 182; + mountData.spawnDustNoGravity = true; + mountData.buff = ModContent.BuffType(); + mountData.heightBoost = 0; + mountData.flightTimeMax = int.MaxValue; + mountData.fatigueMax = int.MaxValue; + mountData.fallDamage = 0f; + mountData.usesHover = true; + mountData.runSpeed = MovementSpeed; + mountData.dashSpeed = MovementSpeed; + mountData.acceleration = MovementSpeed; + mountData.swimSpeed = MovementSpeed; + mountData.jumpHeight = 8; + mountData.jumpSpeed = 8f; + mountData.blockExtraJumps = true; + mountData.totalFrames = 5; + + int[] verticalOffsets = new int[mountData.totalFrames]; + for (int l = 0; l < verticalOffsets.Length; l++) + verticalOffsets[l] = 0; + + mountData.playerYOffsets = verticalOffsets; + mountData.xOffset = 2; + mountData.bodyFrame = 3; + mountData.yOffset = 28; + mountData.playerHeadOffset = 3; + mountData.standingFrameCount = 5; + mountData.standingFrameDelay = 5; + mountData.standingFrameStart = 0; + mountData.runningFrameCount = 5; + mountData.runningFrameDelay = 5; + mountData.runningFrameStart = 0; + mountData.flyingFrameCount = 5; + mountData.flyingFrameDelay = 5; + mountData.flyingFrameStart = 0; + mountData.inAirFrameCount = 5; + mountData.inAirFrameDelay = 5; + mountData.inAirFrameStart = 0; + mountData.idleFrameCount = 5; + mountData.idleFrameDelay = 5; + mountData.idleFrameStart = 0; + mountData.idleFrameLoop = true; + mountData.swimFrameCount = 5; + mountData.swimFrameDelay = 5; + mountData.swimFrameStart = 0; + if (Main.netMode != NetmodeID.Server) + { + mountData.textureWidth = mountData.frontTexture.Width; + mountData.textureHeight = mountData.frontTexture.Height; + } + } + + public override bool Draw(List playerDrawData, int drawType, Player drawPlayer, ref Texture2D texture, ref Texture2D glowTexture, ref Vector2 drawPosition, ref Rectangle frame, ref Color drawColor, ref Color glowColor, ref float rotation, ref SpriteEffects spriteEffects, ref Vector2 drawOrigin, ref float drawScale, float shadow) + { + rotation = drawPlayer.velocity.X * 0.004f; + drawPlayer.fullRotation = rotation; + frame = texture.Frame(1, 5, 0, (int)(Main.GlobalTime * 13f) % 5); + return true; + } + } +} diff --git a/Items/Mounts/DraedonGamerChairMount_Back.png b/Items/Mounts/DraedonGamerChairMount_Back.png new file mode 100644 index 0000000000..c8ebb28168 Binary files /dev/null and b/Items/Mounts/DraedonGamerChairMount_Back.png differ diff --git a/Items/Mounts/DraedonGamerChairMount_Front.png b/Items/Mounts/DraedonGamerChairMount_Front.png new file mode 100644 index 0000000000..093609da69 Binary files /dev/null and b/Items/Mounts/DraedonGamerChairMount_Front.png differ diff --git a/Items/Mounts/DraedonGamerChairMount_Glowmask.png b/Items/Mounts/DraedonGamerChairMount_Glowmask.png new file mode 100644 index 0000000000..fd18744a7f Binary files /dev/null and b/Items/Mounts/DraedonGamerChairMount_Glowmask.png differ diff --git a/Items/Mounts/ExoBox360.cs b/Items/Mounts/ExoBox360.cs new file mode 100644 index 0000000000..645e776af9 --- /dev/null +++ b/Items/Mounts/ExoBox360.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Mounts +{ + public class ExoBox360 : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("ExoBox 360"); + Tooltip.SetDefault("Creates a rideable flying chair\n" + + "Replaced"); + } + + public override void SetDefaults() + { + item.width = 32; + item.height = 34; + item.useTime = item.useAnimation = 20; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = SoundID.Item94; + item.noMelee = true; + item.mountType = ModContent.MountType(); + + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + public override void ModifyTooltips(List list) + { + string hotkey = CalamityMod.ExoChairSpeedupHotkey.TooltipHotkeyString(); + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip1") + line2.text = $"Press {hotkey} when on the chair to move much faster"; + } + } + } +} diff --git a/Items/Mounts/ExoBox360.png b/Items/Mounts/ExoBox360.png new file mode 100644 index 0000000000..48f751425f Binary files /dev/null and b/Items/Mounts/ExoBox360.png differ diff --git a/Items/TreasureBags/DraedonTreasureBag.cs b/Items/TreasureBags/DraedonTreasureBag.cs index 6f7c2ae109..48ff0613c2 100644 --- a/Items/TreasureBags/DraedonTreasureBag.cs +++ b/Items/TreasureBags/DraedonTreasureBag.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; +using CalamityMod.Items.Mounts; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; @@ -61,6 +62,7 @@ namespace CalamityMod.Items.TreasureBags // Equipment DropHelper.DropItem(player, ModContent.ItemType()); + DropHelper.DropItemChance(player, ModContent.ItemType(), 5); // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index bcc4760ce6..34f8151dbe 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -2,6 +2,7 @@ using CalamityMod.Events; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; +using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -756,6 +757,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares DropHelper.WeightStack(w) ); + // Equipment + DropHelper.DropItemChance(npc, ModContent.ItemType(), 5); + // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index 9c293962e4..5d3e4c0f11 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -113,6 +113,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // The point to spin around private Vector2 spinningPoint = default; + // Velocity for the spin + private Vector2 spinVelocity = default; + // Intensity of flash effects during the charge combo public float ChargeFlash; @@ -167,6 +170,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public override void SendExtraAI(BinaryWriter writer) { + writer.WriteVector2(spinVelocity); writer.WriteVector2(chargeVelocityNormalized); writer.Write(frameX); writer.Write(frameY); @@ -184,6 +188,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public override void ReceiveExtraAI(BinaryReader reader) { + spinVelocity = reader.ReadVector2(); chargeVelocityNormalized = reader.ReadVector2(); frameX = reader.ReadInt32(); frameY = reader.ReadInt32(); @@ -454,6 +459,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; npc.dontTakeDamage = true; npc.velocity.Y -= 1f; @@ -549,6 +555,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; } } else @@ -570,6 +577,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; } // Go passive and immune if one of the other mechs is berserk @@ -588,6 +596,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; } } @@ -614,6 +623,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; } // If Artemis and Apollo are the first mechs to go berserk @@ -630,6 +640,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; // Never be passive if berserk SecondaryAIState = (float)SecondaryPhase.Nothing; @@ -659,6 +670,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; } if (berserk) @@ -674,6 +686,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; chargeVelocityNormalized = default; spinningPoint = default; + spinVelocity = default; // Never be passive if berserk SecondaryAIState = (float)SecondaryPhase.Nothing; @@ -933,8 +946,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = player.direction; // Set spin velocity - npc.velocity.X = MathHelper.Pi * spinRadius / spinTime; - npc.velocity *= -rotationDirection; + spinVelocity.X = MathHelper.Pi * spinRadius / spinTime; + spinVelocity *= -rotationDirection; npc.netUpdate = true; // Create a bunch of lightning bolts in the sky @@ -954,7 +967,24 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis } } else - npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinTime * -rotationDirection); + { + // This is used to adjust both the radians and the velocity of the spin moved per frame + float rotationMult = (calamityGlobalNPC.newAI[2] - deathrayTelegraphDuration) / deathrayDuration * 4f; + if (rotationMult > 1f) + { + // The radians moved per frame during the spin + double radiansOfRotation = MathHelper.Pi / spinTime * -rotationDirection; + npc.velocity = npc.velocity.RotatedBy(radiansOfRotation); + } + else + { + // The radians moved per frame during the spin + // The radians moved are reduced early on to avoid spinning too fucking fast + float decelerationMult = rotationMult * rotationMult; + double radiansOfRotation = MathHelper.Pi / spinTime * -rotationDirection * decelerationMult; + npc.velocity = (spinVelocity * decelerationMult).RotatedBy(radiansOfRotation); + } + } } } else @@ -980,6 +1010,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Reset phase and variables if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) { + spinVelocity = default; rotationDirection = 0; spinningPoint = default; pickNewLocation = true;