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 17d78df217..9fc91d9183 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -326,6 +326,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; @@ -1529,6 +1530,7 @@ namespace CalamityMod.CalPlayer angryDog = false; fab = false; crysthamyr = false; + ExoChair = false; miniOldDuke = false; abyssalDivingSuitPlates = false; @@ -2296,6 +2298,7 @@ namespace CalamityMod.CalPlayer angryDog = false; fab = false; crysthamyr = false; + ExoChair = false; abyssalDivingSuitPlates = false; sirenWaterBuff = false; sirenIce = false; @@ -3929,6 +3932,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 e1f03a83fd..b19354cbdb 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/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index 6850933782..dfac76cf88 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -496,13 +496,12 @@ namespace CalamityMod.ILEditing private static void ManipulateSoundMuffleFactor(ILContext il) { ILCursor cursor = new ILCursor(il); - cursor.GotoNext(MoveType.After, i => i.MatchStloc(30)); - cursor.Index--; + cursor.GotoNext(MoveType.Before, i => i.MatchStloc(30)); cursor.Emit(OpCodes.Ldloc, 20); cursor.EmitDelegate>(originalMuffleFactor => { - if (Main.gameMenu) + if (Main.gameMenu || !Main.LocalPlayer.active) return originalMuffleFactor; float playerMuffleFactor = 1f - Main.LocalPlayer.Calamity().MusicMuffleFactor; @@ -511,8 +510,8 @@ namespace CalamityMod.ILEditing { for (int i = 0; i < Main.music.Length; i++) { - if (Main.music[i]?.IsPlaying ?? false) - Main.music[i]?.Stop(AudioStopOptions.Immediate); + if (Main.music[i] != null && Main.music[i].IsPlaying) + Main.music[i].Stop(AudioStopOptions.Immediate); } Main.curMusic = 0; } 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 ffe2302f0c..75bdb8b915 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.Potions; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Melee; @@ -751,6 +752,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);