Merge branch 'master' into exo-mech-visuals

This commit is contained in:
Dominic committed 2021-09-30 14:45:04 -05:00
commit c05da8df5f
13 files changed
+228 -4

No files matched your search

+24
View File
@@ -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<DraedonGamerChairMount>(), player);
player.buffTime[buffIndex] = 10;
player.Calamity().ExoChair = true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

+44
View File
@@ -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
+3 -1
View File
@@ -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();
+77
View File
@@ -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<DraedonGamerChairBuff>();
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<DrawData> 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;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

+40
View File
@@ -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<DraedonGamerChairMount>();
item.value = CalamityGlobalItem.RarityVioletBuyPrice;
item.Calamity().customRarity = CalamityRarity.Violet;
}
public override void ModifyTooltips(List<TooltipLine> 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";
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

+2
View File
@@ -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<DraedonsHeart>());
DropHelper.DropItemChance(player, ModContent.ItemType<ExoBox360>(), 5);
// Vanity
DropHelper.DropItemChance(player, ModContent.ItemType<ThanosMask>(), 7);
+4
View File
@@ -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<TheAtomSplitter>(w)
);
// Equipment
DropHelper.DropItemChance(npc, ModContent.ItemType<ExoBox360>(), 5);
// Vanity
DropHelper.DropItemChance(npc, ModContent.ItemType<ThanosMask>(), 7);
DropHelper.DropItemChance(npc, ModContent.ItemType<ArtemisMask>(), 7);
+34 -3
View File
@@ -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;