diff --git a/Content/DecimationPlayerImpl.cs b/Content/DecimationPlayerImpl.cs index 800f576..f44aca8 100644 --- a/Content/DecimationPlayerImpl.cs +++ b/Content/DecimationPlayerImpl.cs @@ -1,11 +1,12 @@ using System; +using System.Collections.Generic; using Decimation.Content.Buffs.Buffs; +using Decimation.Content.Items.Amulets; +using Decimation.Content.Items.Misc; using Decimation.Lib; using Decimation.Lib.Amulets; using Decimation.Lib.Collections; using Decimation.Lib.Util; -using Decimation.Content.Items.Amulets; -using Decimation.Content.Items.Misc; using Microsoft.Xna.Framework; using Terraria; using Terraria.Graphics.Shaders; @@ -42,7 +43,6 @@ namespace Decimation.Content // Effects public bool hasCursedAccessory; public byte hyperStars; - public byte soulFruits; public bool isInCombat; public bool jestersQuiverEquiped; @@ -58,6 +58,7 @@ namespace Decimation.Content // Scarab shield public int solarCounter = 0; + public byte soulFruits; public bool tideTurnerEquipped; public int ttDash; public int ttHit; @@ -67,6 +68,7 @@ namespace Decimation.Content // Slimy Feet buff public bool wasJumping = false; + public ICollection EquippedAccessories { get; } = new List(); public override bool HasShield { get; set; } public override bool HasLavaCharm { get; set; } @@ -82,12 +84,14 @@ namespace Decimation.Content public override void Initialize() { - this.AmuletSlotItem = new Item(); - this.AmuletSlotItem.SetDefaults(0, true); + AmuletSlotItem = new Item(); + AmuletSlotItem.SetDefaults(0, true); } public override void ResetEffects() { + EquippedAccessories.Clear(); + closeToEnchantedAnvil = false; jestersQuiverEquiped = false; deadeyesQuiverEquipped = false; @@ -97,13 +101,13 @@ namespace Decimation.Content tideTurnerEquipped = false; vampire = false; - this.HasLavaCharm = false; - this.HasShield = false; + HasLavaCharm = false; + HasShield = false; hasCursedAccessory = false; - this.player.statManaMax2 += hyperStars * HyperStar.ManaHealAmount; - this.player.statLifeMax2 += soulFruits * SoulFruit.LifeHealAmount; + player.statManaMax2 += hyperStars * HyperStar.ManaHealAmount; + player.statLifeMax2 += soulFruits * SoulFruit.LifeHealAmount; if (combatTime > 360) { @@ -117,8 +121,8 @@ namespace Decimation.Content amuletsBuffTime = 0; amuletsBuffWhenAttacking = false; - if (!this.player.HasBuff(ModContent.BuffType())) lastJumpBoost = 0; - if (!this.player.HasBuff(ModContent.BuffType())) + if (!player.HasBuff(ModContent.BuffType())) lastJumpBoost = 0; + if (!player.HasBuff(ModContent.BuffType())) { scarabEnduranceBuffTimeCounter = 0; scarabCounter = 0; @@ -137,17 +141,17 @@ namespace Decimation.Content return new TagCompound { - {"amuletSlotItem", ItemIO.Save(this.AmuletSlotItem)}, - {"hyperStars", this.hyperStars}, + {"amuletSlotItem", ItemIO.Save(AmuletSlotItem)}, + {"hyperStars", hyperStars}, {"soulFruits", soulFruits} }; } public override void Load(TagCompound tag) { - this.AmuletSlotItem = ItemIO.Load(tag.GetCompound("amuletSlotItem")); - this.hyperStars = tag.GetByte("hyperStars"); - this.soulFruits = tag.GetByte("soulFruits"); + AmuletSlotItem = ItemIO.Load(tag.GetCompound("amuletSlotItem")); + hyperStars = tag.GetByte("hyperStars"); + soulFruits = tag.GetByte("soulFruits"); } // FIND AN ALTERNATIVE! THIS METHOD DOESN'T GET CALLED WITH EVERY WEAPONS @@ -177,7 +181,7 @@ namespace Decimation.Content } // Frost Amulet - if (this.AmuletSlotItem.type == ModContent.ItemType() && toCheck.arrow) + if (AmuletSlotItem.type == ModContent.ItemType() && toCheck.arrow) { speedX *= 1.03f; speedY *= 1.03f; @@ -196,10 +200,10 @@ namespace Decimation.Content return false; if (endlessPouchofLifeEquipped && ammo.ammo == AmmoID.Bullet) return false; - if (this.AmuletSlotItem.type == ModContent.ItemType() && ammo.ammo == AmmoID.Arrow && + if (AmuletSlotItem.type == ModContent.ItemType() && ammo.ammo == AmmoID.Arrow && Main.rand.NextBool(50)) return false; - if (this.AmuletSlotItem.type == ModContent.ItemType() && weapon.thrown && + if (AmuletSlotItem.type == ModContent.ItemType() && weapon.thrown && Main.rand.NextBool(50) && weapon.thrown) return false; @@ -225,15 +229,15 @@ namespace Decimation.Content { if (vampire) { - this.player.head = 124; - this.player.body = 85; - this.player.legs = 72; + player.head = 124; + player.body = 85; + player.legs = 72; } } public override void PostUpdate() { - oldStatDefense = this.player.statDefense; + oldStatDefense = player.statDefense; if (lastHitCounter >= 60) { @@ -257,14 +261,14 @@ namespace Decimation.Content public override void OnHitPvp(Item item, Player target, int damage, bool crit) { - if (target.HasBuff(ModContent.BuffType())) this.player.AddBuff(BuffID.OnFire, 300); + if (target.HasBuff(ModContent.BuffType())) player.AddBuff(BuffID.OnFire, 300); if (amuletsBuffTime != 0 && amuletsBuff != 0 && amuletsBuffChances != 0 && amuletsBuffWhenAttacking && - this.AmuletSlotItem.type != ModContent.ItemType()) + AmuletSlotItem.type != ModContent.ItemType()) if (Main.rand.Next(amuletsBuffChances, 100) < amuletsBuffChances) target.AddBuff(amuletsBuff, amuletsBuffTime); - if (this.AmuletSlotItem.type == ModContent.ItemType()) + if (AmuletSlotItem.type == ModContent.ItemType()) CrystalAmuletEffect(); } @@ -274,7 +278,7 @@ namespace Decimation.Content combatTime = 0; if (amuletsBuffTime != 0 && amuletsBuff != 0 && amuletsBuffChances != 0 && amuletsBuffWhenAttacking && - this.AmuletSlotItem.type != ModContent.ItemType()) + AmuletSlotItem.type != ModContent.ItemType()) if (Main.rand.Next(amuletsBuffChances, 100) < amuletsBuffChances) target.AddBuff(amuletsBuff, amuletsBuffTime); } @@ -282,8 +286,8 @@ namespace Decimation.Content public override void OnHitPvpWithProj(Projectile proj, Player target, int damage, bool crit) { if (amuletsBuffTime != 0 && amuletsBuff != 0 && amuletsBuffChances != 0 && amuletsBuffWhenAttacking && - (this.AmuletSlotItem.type != ModContent.ItemType() || - this.AmuletSlotItem.type == ModContent.ItemType() && proj.thrown)) + (AmuletSlotItem.type != ModContent.ItemType() || + AmuletSlotItem.type == ModContent.ItemType() && proj.thrown)) if (Main.rand.Next(amuletsBuffChances, 100) < amuletsBuffChances) target.AddBuff(amuletsBuff, amuletsBuffTime); } @@ -294,15 +298,15 @@ namespace Decimation.Content combatTime = 0; if (amuletsBuffTime != 0 && amuletsBuff != 0 && amuletsBuffChances != 0 && amuletsBuffWhenAttacking && - (this.AmuletSlotItem.type != ModContent.ItemType() || - this.AmuletSlotItem.type == ModContent.ItemType() && proj.thrown)) + (AmuletSlotItem.type != ModContent.ItemType() || + AmuletSlotItem.type == ModContent.ItemType() && proj.thrown)) if (Main.rand.Next(amuletsBuffChances, 100) < amuletsBuffChances) target.AddBuff(amuletsBuff, amuletsBuffTime); } public override void OnHitByNPC(NPC npc, int damage, bool crit) { - if (this.player.HasBuff(ModContent.BuffType()) && scarabCounter > 0 && + if (player.HasBuff(ModContent.BuffType()) && scarabCounter > 0 && lastHitCounter == 0 && !wasHurt) { @@ -317,7 +321,7 @@ namespace Decimation.Content if (graniteLinedTunicEquipped) { - this.player.statLife += (int) (damage * 0.04f); + player.statLife += (int) (damage * 0.04f); if (Main.rand.Next(3, 100) < 3) npc.AddBuff(BuffID.Confused, 600); @@ -325,26 +329,25 @@ namespace Decimation.Content if (tideTurnerEquipped && Main.rand.NextBool(2)) { - Main.NewText("Tide Turner"); - this.player.statLife += damage; + player.statLife += damage; } foreach (Player otherPlayer in Main.player) - if (otherPlayer.whoAmI != this.player.whoAmI) + if (otherPlayer.whoAmI != player.whoAmI) if (otherPlayer.GetModPlayer().AmuletSlotItem.type == - ModContent.ItemType() && otherPlayer.team == this.player.team) + ModContent.ItemType() && otherPlayer.team == player.team) { - this.player.statLife += (int) (damage * 0.03f); + player.statLife += (int) (damage * 0.03f); break; } - if (this.AmuletSlotItem.type == ModContent.ItemType() && Main.rand.NextBool(25)) + if (AmuletSlotItem.type == ModContent.ItemType() && Main.rand.NextBool(25)) CrystalAmuletEffect(); } public override void OnHitByProjectile(Projectile proj, int damage, bool crit) { - if (this.player.HasBuff(ModContent.BuffType()) && scarabCounter > 0 && + if (player.HasBuff(ModContent.BuffType()) && scarabCounter > 0 && lastHitCounter == 0 && !wasHurt) { @@ -363,7 +366,7 @@ namespace Decimation.Content if (graniteLinedTunicEquipped) { - this.player.statLife += (int) (damage * 0.04f); + player.statLife += (int) (damage * 0.04f); if (proj.npcProj && Main.rand.Next(3, 100) < 3) Main.npc[proj.owner].AddBuff(BuffID.Confused, 600); @@ -372,15 +375,15 @@ namespace Decimation.Content } foreach (Player otherPlayer in Main.player) - if (otherPlayer.whoAmI != this.player.whoAmI) + if (otherPlayer.whoAmI != player.whoAmI) if (otherPlayer.GetModPlayer().AmuletSlotItem.type == - ModContent.ItemType() && otherPlayer.team == this.player.team) + ModContent.ItemType() && otherPlayer.team == player.team) { - this.player.statLife += (int) (damage * 0.03f); + player.statLife += (int) (damage * 0.03f); break; } - if (this.AmuletSlotItem.type == ModContent.ItemType() && Main.rand.NextBool(25)) + if (AmuletSlotItem.type == ModContent.ItemType() && Main.rand.NextBool(25)) CrystalAmuletEffect(); } @@ -401,80 +404,80 @@ namespace Decimation.Content if (ttHit < 0) { Rectangle rectangle = - new Rectangle((int) (this.player.position.X + this.player.velocity.X * 0.5 - 4.0), - (int) (this.player.position.Y + this.player.velocity.Y * 0.5 - 4.0), this.player.width + 8, - this.player.height + 8); + new Rectangle((int) (player.position.X + player.velocity.X * 0.5 - 4.0), + (int) (player.position.Y + player.velocity.Y * 0.5 - 4.0), player.width + 8, + player.height + 8); for (int i = 0; i < 200; i++) if (Main.npc[i].active && !Main.npc[i].dontTakeDamage && !Main.npc[i].friendly) { NPC nPC = Main.npc[i]; Rectangle rect = nPC.getRect(); - if (rectangle.Intersects(rect) && (nPC.noTileCollide || this.player.CanHit(nPC))) + if (rectangle.Intersects(rect) && (nPC.noTileCollide || player.CanHit(nPC))) { - float num = dashDamages * this.player.meleeDamage; + float num = dashDamages * player.meleeDamage; float num2 = 9f; bool crit = false; - if (this.player.kbGlove) num2 *= 2f; - if (this.player.kbBuff) num2 *= 1.5f; - if (Main.rand.Next(100) < this.player.meleeCrit) crit = true; - int num3 = this.player.direction; - if (this.player.velocity.X < 0f) num3 = -1; - if (this.player.velocity.X > 0f) num3 = 1; - if (this.player.whoAmI == Main.myPlayer) - this.player.ApplyDamageToNPC(nPC, (int) num, num2, num3, crit); + if (player.kbGlove) num2 *= 2f; + if (player.kbBuff) num2 *= 1.5f; + if (Main.rand.Next(100) < player.meleeCrit) crit = true; + int num3 = player.direction; + if (player.velocity.X < 0f) num3 = -1; + if (player.velocity.X > 0f) num3 = 1; + if (player.whoAmI == Main.myPlayer) + player.ApplyDamageToNPC(nPC, (int) num, num2, num3, crit); ttDash = 10; dashDelay = 30; - this.player.velocity.X = (0f - num3) * 9f; - this.player.velocity.Y = -4f; - this.player.immune = true; - this.player.immuneNoBlink = true; - this.player.immuneTime = 4; + player.velocity.X = (0f - num3) * 9f; + player.velocity.Y = -4f; + player.immune = true; + player.immuneNoBlink = true; + player.immuneTime = 4; ttHit = i; } } } - else if ((!this.player.controlLeft || this.player.velocity.X >= 0f) && - (!this.player.controlRight || this.player.velocity.X <= 0f)) + else if ((!player.controlLeft || player.velocity.X >= 0f) && + (!player.controlRight || player.velocity.X <= 0f)) { - this.player.velocity.X = this.player.velocity.X * 0.95f; + player.velocity.X = player.velocity.X * 0.95f; } } - if (dash == 3 && dashDelay < 0 && this.player.whoAmI == Main.myPlayer) + if (dash == 3 && dashDelay < 0 && player.whoAmI == Main.myPlayer) { Rectangle rectangle2 = - new Rectangle((int) (this.player.position.X + this.player.velocity.X * 0.5 - 4.0), - (int) (this.player.position.Y + this.player.velocity.Y * 0.5 - 4.0), this.player.width + 8, - this.player.height + 8); + new Rectangle((int) (player.position.X + player.velocity.X * 0.5 - 4.0), + (int) (player.position.Y + player.velocity.Y * 0.5 - 4.0), player.width + 8, + player.height + 8); for (int j = 0; j < 200; j++) if (Main.npc[j].active && !Main.npc[j].dontTakeDamage && !Main.npc[j].friendly && - Main.npc[j].immune[this.player.whoAmI] <= 0) + Main.npc[j].immune[player.whoAmI] <= 0) { NPC nPC2 = Main.npc[j]; Rectangle rect2 = nPC2.getRect(); - if (rectangle2.Intersects(rect2) && (nPC2.noTileCollide || this.player.CanHit(nPC2))) + if (rectangle2.Intersects(rect2) && (nPC2.noTileCollide || player.CanHit(nPC2))) { - float num4 = 150f * this.player.meleeDamage; + float num4 = 150f * player.meleeDamage; float num5 = 9f; bool crit2 = false; - if (this.player.kbGlove) num5 *= 2f; - if (this.player.kbBuff) num5 *= 1.5f; - if (Main.rand.Next(100) < this.player.meleeCrit) crit2 = true; - int direction = this.player.direction; - if (this.player.velocity.X < 0f) direction = -1; - if (this.player.velocity.X > 0f) direction = 1; - if (this.player.whoAmI == Main.myPlayer) + if (player.kbGlove) num5 *= 2f; + if (player.kbBuff) num5 *= 1.5f; + if (Main.rand.Next(100) < player.meleeCrit) crit2 = true; + int direction = player.direction; + if (player.velocity.X < 0f) direction = -1; + if (player.velocity.X > 0f) direction = 1; + if (player.whoAmI == Main.myPlayer) { - this.player.ApplyDamageToNPC(nPC2, (int) num4, num5, direction, crit2); - int num6 = Projectile.NewProjectile(this.player.Center.X, this.player.Center.Y, 0f, 0f, + player.ApplyDamageToNPC(nPC2, (int) num4, num5, direction, crit2); + int num6 = Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, 0f, 608, 150, 15f, Main.myPlayer); Main.projectile[num6].Kill(); } - nPC2.immune[this.player.whoAmI] = 6; - this.player.immune = true; - this.player.immuneNoBlink = true; - this.player.immuneTime = 4; + nPC2.immune[player.whoAmI] = 6; + player.immune = true; + player.immuneNoBlink = true; + player.immuneTime = 4; } } } @@ -489,43 +492,43 @@ namespace Decimation.Content { float num7 = 12f; float num8 = 0.992f; - float num9 = Math.Max(this.player.accRunSpeed, this.player.maxRunSpeed); + float num9 = Math.Max(player.accRunSpeed, player.maxRunSpeed); float num10 = 0.96f; int num11 = 20; if (dash == 1) { for (int k = 0; k < 2; k++) { - int num12 = this.player.velocity.Y != 0f + int num12 = player.velocity.Y != 0f ? Dust.NewDust( - new Vector2(this.player.position.X, - this.player.position.Y + this.player.height / 2 - 8f), this.player.width, 16, 31, + new Vector2(player.position.X, + player.position.Y + player.height / 2 - 8f), player.width, 16, 31, 0f, 0f, 100, default, 1.4f) : Dust.NewDust( - new Vector2(this.player.position.X, this.player.position.Y + this.player.height - 4f), - this.player.width, 8, 31, 0f, 0f, 100, default, 1.4f); + new Vector2(player.position.X, player.position.Y + player.height - 4f), + player.width, 8, 31, 0f, 0f, 100, default, 1.4f); Dust obj = Main.dust[num12]; obj.velocity *= 0.1f; Main.dust[num12].scale *= 1f + Main.rand.Next(20) * 0.01f; - Main.dust[num12].shader = GameShaders.Armor.GetSecondaryShader(this.player.cShoe, this.player); + Main.dust[num12].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } } else if (dash == 2) { for (int l = 0; l < 0; l++) { - int num13 = this.player.velocity.Y != 0f + int num13 = player.velocity.Y != 0f ? Dust.NewDust( - new Vector2(this.player.position.X, - this.player.position.Y + this.player.height / 2 - 8f), this.player.width, 16, 31, + new Vector2(player.position.X, + player.position.Y + player.height / 2 - 8f), player.width, 16, 31, 0f, 0f, 100, default, 1.4f) : Dust.NewDust( - new Vector2(this.player.position.X, this.player.position.Y + this.player.height - 4f), - this.player.width, 8, 31, 0f, 0f, 100, default, 1.4f); + new Vector2(player.position.X, player.position.Y + player.height - 4f), + player.width, 8, 31, 0f, 0f, 100, default, 1.4f); Dust obj2 = Main.dust[num13]; obj2.velocity *= 0.1f; Main.dust[num13].scale *= 1f + Main.rand.Next(20) * 0.01f; - Main.dust[num13].shader = GameShaders.Armor.GetSecondaryShader(this.player.cShoe, this.player); + Main.dust[num13].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } num8 = 0.985f; @@ -536,13 +539,13 @@ namespace Decimation.Content { for (int m = 0; m < 4; m++) { - int num14 = Dust.NewDust(new Vector2(this.player.position.X, this.player.position.Y + 4f), - this.player.width, this.player.height - 8, 6, 0f, 0f, 100, default, 1.7f); + int num14 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 4f), + player.width, player.height - 8, 6, 0f, 0f, 100, default, 1.7f); Dust obj3 = Main.dust[num14]; obj3.velocity *= 0.1f; Main.dust[num14].scale *= 1f + Main.rand.Next(20) * 0.01f; Main.dust[num14].shader = - GameShaders.Armor.GetSecondaryShader(this.player.ArmorSetDye(), this.player); + GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); Main.dust[num14].noGravity = true; if (Main.rand.Next(2) == 0) Main.dust[num14].fadeIn = 0.5f; } @@ -556,12 +559,12 @@ namespace Decimation.Content { for (int n = 0; n < 2; n++) { - int num15 = Dust.NewDust(new Vector2(this.player.position.X, this.player.position.Y + 4f), - this.player.width, this.player.height - 8, 229, 0f, 0f, 100, default, 1.2f); + int num15 = Dust.NewDust(new Vector2(player.position.X, player.position.Y + 4f), + player.width, player.height - 8, 229, 0f, 0f, 100, default, 1.2f); Dust obj4 = Main.dust[num15]; obj4.velocity *= 0.1f; Main.dust[num15].scale *= 1f + Main.rand.Next(20) * 0.01f; - Main.dust[num15].shader = GameShaders.Armor.GetSecondaryShader(this.player.cWings, this.player); + Main.dust[num15].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); Main.dust[num15].noGravity = true; if (Main.rand.Next(2) == 0) Main.dust[num15].fadeIn = 0.3f; } @@ -573,25 +576,25 @@ namespace Decimation.Content if (dash > 0) { - this.player.vortexStealthActive = false; - if (this.player.velocity.X > num7 || this.player.velocity.X < 0f - num7) + player.vortexStealthActive = false; + if (player.velocity.X > num7 || player.velocity.X < 0f - num7) { - this.player.velocity.X = this.player.velocity.X * num8; + player.velocity.X = player.velocity.X * num8; } - else if (this.player.velocity.X > num9 || this.player.velocity.X < 0f - num9) + else if (player.velocity.X > num9 || player.velocity.X < 0f - num9) { - this.player.velocity.X = this.player.velocity.X * num10; + player.velocity.X = player.velocity.X * num10; } else { dashDelay = num11; - if (this.player.velocity.X < 0f) - this.player.velocity.X = 0f - num9; - else if (this.player.velocity.X > 0f) this.player.velocity.X = num9; + if (player.velocity.X < 0f) + player.velocity.X = 0f - num9; + else if (player.velocity.X > 0f) player.velocity.X = num9; } } } - else if (dash > 0 && !this.player.mount.Active) + else if (dash > 0 && !player.mount.Active) { if (dash == 1) { @@ -599,7 +602,7 @@ namespace Decimation.Content bool flag = false; if (dashTime > 0) dashTime--; if (dashTime < 0) dashTime++; - if (this.player.controlRight && this.player.releaseRight) + if (player.controlRight && player.releaseRight) { if (dashTime > 0) { @@ -612,7 +615,7 @@ namespace Decimation.Content dashTime = 15; } } - else if (this.player.controlLeft && this.player.releaseLeft) + else if (player.controlLeft && player.releaseLeft) { if (dashTime < 0) { @@ -628,20 +631,20 @@ namespace Decimation.Content if (flag) { - this.player.velocity.X = 16.9f * num16; - Point point = (this.player.Center + new Vector2(num16 * this.player.width / 2 + 2, - this.player.gravDir * (0f - this.player.height) / 2f + - this.player.gravDir * 2f)).ToTileCoordinates(); - Point point2 = (this.player.Center + new Vector2(num16 * this.player.width / 2 + 2, 0f)) + player.velocity.X = 16.9f * num16; + Point point = (player.Center + new Vector2(num16 * player.width / 2 + 2, + player.gravDir * (0f - player.height) / 2f + + player.gravDir * 2f)).ToTileCoordinates(); + Point point2 = (player.Center + new Vector2(num16 * player.width / 2 + 2, 0f)) .ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(point.X, point.Y) || WorldGen.SolidOrSlopedTile(point2.X, point2.Y)) - this.player.velocity.X = this.player.velocity.X / 2f; + player.velocity.X = player.velocity.X / 2f; dashDelay = -1; for (int num17 = 0; num17 < 20; num17++) { - int num18 = Dust.NewDust(new Vector2(this.player.position.X, this.player.position.Y), - this.player.width, this.player.height, 31, 0f, 0f, 100, default, 2f); + int num18 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), + player.width, player.height, 31, 0f, 0f, 100, default, 2f); Dust dust = Main.dust[num18]; dust.position.X = dust.position.X + Main.rand.Next(-5, 6); Dust dust2 = Main.dust[num18]; @@ -650,20 +653,20 @@ namespace Decimation.Content obj5.velocity *= 0.2f; Main.dust[num18].scale *= 1f + Main.rand.Next(20) * 0.01f; Main.dust[num18].shader = - GameShaders.Armor.GetSecondaryShader(this.player.cShoe, this.player); + GameShaders.Armor.GetSecondaryShader(player.cShoe, player); } int num19 = Gore.NewGore( - new Vector2(this.player.position.X + this.player.width / 2 - 24f, - this.player.position.Y + this.player.height / 2 - 34f), default, + new Vector2(player.position.X + player.width / 2 - 24f, + player.position.Y + player.height / 2 - 34f), default, Main.rand.Next(61, 64)); Main.gore[num19].velocity.X = Main.rand.Next(-50, 51) * 0.01f; Main.gore[num19].velocity.Y = Main.rand.Next(-50, 51) * 0.01f; Gore obj6 = Main.gore[num19]; obj6.velocity *= 0.4f; num19 = Gore.NewGore( - new Vector2(this.player.position.X + this.player.width / 2 - 24f, - this.player.position.Y + this.player.height / 2 - 14f), default, + new Vector2(player.position.X + player.width / 2 - 24f, + player.position.Y + player.height / 2 - 14f), default, Main.rand.Next(61, 64)); Main.gore[num19].velocity.X = Main.rand.Next(-50, 51) * 0.01f; Main.gore[num19].velocity.Y = Main.rand.Next(-50, 51) * 0.01f; @@ -677,7 +680,7 @@ namespace Decimation.Content bool flag2 = false; if (dashTime > 0) dashTime--; if (dashTime < 0) dashTime++; - if (this.player.controlRight && this.player.releaseRight) + if (player.controlRight && player.releaseRight) { if (dashTime > 0) { @@ -690,7 +693,7 @@ namespace Decimation.Content dashTime = 15; } } - else if (this.player.controlLeft && this.player.releaseLeft) + else if (player.controlLeft && player.releaseLeft) { if (dashTime < 0) { @@ -706,21 +709,21 @@ namespace Decimation.Content if (flag2) { - this.player.velocity.X = 14.5f * num20; - Point point3 = (this.player.Center + new Vector2(num20 * this.player.width / 2 + 2, - this.player.gravDir * (0f - this.player.height) / 2f + - this.player.gravDir * 2f)).ToTileCoordinates(); - Point point4 = (this.player.Center + new Vector2(num20 * this.player.width / 2 + 2, 0f)) + player.velocity.X = 14.5f * num20; + Point point3 = (player.Center + new Vector2(num20 * player.width / 2 + 2, + player.gravDir * (0f - player.height) / 2f + + player.gravDir * 2f)).ToTileCoordinates(); + Point point4 = (player.Center + new Vector2(num20 * player.width / 2 + 2, 0f)) .ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(point3.X, point3.Y) || WorldGen.SolidOrSlopedTile(point4.X, point4.Y)) - this.player.velocity.X = this.player.velocity.X / 2f; + player.velocity.X = player.velocity.X / 2f; dashDelay = -1; ttDash = 15; for (int num21 = 0; num21 < 0; num21++) { - int num22 = Dust.NewDust(new Vector2(this.player.position.X, this.player.position.Y), - this.player.width, this.player.height, 31, 0f, 0f, 100, default, 2f); + int num22 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), + player.width, player.height, 31, 0f, 0f, 100, default, 2f); Dust dust3 = Main.dust[num22]; dust3.position.X = dust3.position.X + Main.rand.Next(-5, 6); Dust dust4 = Main.dust[num22]; @@ -729,7 +732,7 @@ namespace Decimation.Content obj8.velocity *= 0.2f; Main.dust[num22].scale *= 1f + Main.rand.Next(20) * 0.01f; Main.dust[num22].shader = - GameShaders.Armor.GetSecondaryShader(this.player.cShield, this.player); + GameShaders.Armor.GetSecondaryShader(player.cShield, player); } } } @@ -739,7 +742,7 @@ namespace Decimation.Content bool flag3 = false; if (dashTime > 0) dashTime--; if (dashTime < 0) dashTime++; - if (this.player.controlRight && this.player.releaseRight) + if (player.controlRight && player.releaseRight) { if (dashTime > 0) { @@ -752,7 +755,7 @@ namespace Decimation.Content dashTime = 15; } } - else if (this.player.controlLeft && this.player.releaseLeft) + else if (player.controlLeft && player.releaseLeft) { if (dashTime < 0) { @@ -768,20 +771,20 @@ namespace Decimation.Content if (flag3) { - this.player.velocity.X = 21.9f * num23; - Point point5 = (this.player.Center + new Vector2(num23 * this.player.width / 2 + 2, - this.player.gravDir * (0f - this.player.height) / 2f + - this.player.gravDir * 2f)).ToTileCoordinates(); - Point point6 = (this.player.Center + new Vector2(num23 * this.player.width / 2 + 2, 0f)) + player.velocity.X = 21.9f * num23; + Point point5 = (player.Center + new Vector2(num23 * player.width / 2 + 2, + player.gravDir * (0f - player.height) / 2f + + player.gravDir * 2f)).ToTileCoordinates(); + Point point6 = (player.Center + new Vector2(num23 * player.width / 2 + 2, 0f)) .ToTileCoordinates(); if (WorldGen.SolidOrSlopedTile(point5.X, point5.Y) || WorldGen.SolidOrSlopedTile(point6.X, point6.Y)) - this.player.velocity.X = this.player.velocity.X / 2f; + player.velocity.X = player.velocity.X / 2f; dashDelay = -1; for (int num24 = 0; num24 < 20; num24++) { - int num25 = Dust.NewDust(new Vector2(this.player.position.X, this.player.position.Y), - this.player.width, this.player.height, 6, 0f, 0f, 100, default, 2f); + int num25 = Dust.NewDust(new Vector2(player.position.X, player.position.Y), + player.width, player.height, 6, 0f, 0f, 100, default, 2f); Dust dust5 = Main.dust[num25]; dust5.position.X = dust5.position.X + Main.rand.Next(-5, 6); Dust dust6 = Main.dust[num25]; @@ -790,7 +793,7 @@ namespace Decimation.Content obj9.velocity *= 0.2f; Main.dust[num25].scale *= 1f + Main.rand.Next(20) * 0.01f; Main.dust[num25].shader = - GameShaders.Armor.GetSecondaryShader(this.player.ArmorSetDye(), this.player); + GameShaders.Armor.GetSecondaryShader(player.ArmorSetDye(), player); Main.dust[num25].noGravity = true; Main.dust[num25].fadeIn = 0.5f; } @@ -811,8 +814,8 @@ namespace Decimation.Content float speedX = (float) Math.Cos(currentAngle) * speed; float speedY = (float) Math.Sin(currentAngle) * speed; - Projectile.NewProjectile(this.player.Center, new Vector2(speedX, speedY), ProjectileID.CrystalShard, 20, - 5, this.player.whoAmI); + Projectile.NewProjectile(player.Center, new Vector2(speedX, speedY), ProjectileID.CrystalShard, 20, + 5, player.whoAmI); currentAngle += angleDifference; } diff --git a/Content/Items/Accessories/RedHotShackle.cs b/Content/Items/Accessories/RedHotShackle.cs index a1b35ae..efd6387 100644 --- a/Content/Items/Accessories/RedHotShackle.cs +++ b/Content/Items/Accessories/RedHotShackle.cs @@ -1,19 +1,17 @@ -using System; using System.Collections.Generic; -using Microsoft.Xna.Framework; +using Decimation.Content.Buffs.Debuffs; +using Decimation.Lib.Items; +using Decimation.Lib.Util; using Terraria; -using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; - using Decimation.Lib.Items; -using Decimation.Lib.Util; namespace Decimation.Content.Items.Accessories { internal class RedHotShackle : DecimationAccessory { protected override string ItemName => "Red Hot Shackle"; - protected override string ItemTooltip => "WIP"; + protected override string ItemTooltip => "Your attackers gain Singed for 6 seconds."; protected override void InitAccessory() { @@ -23,15 +21,29 @@ namespace Decimation.Content.Items.Accessories item.value = Item.buyPrice(0, 0, 2); item.defense = 1; } - + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.EquipAccessory(this); + } + protected override List GetAdditionalRecipes() { - ModRecipe recipe = GetNewModRecipe(this, 1, new List() { TileID.Furnaces }, true); + ModRecipe recipe = GetNewModRecipe(this, 1, new List() {TileID.Furnaces}, true); recipe.AddIngredient(ItemID.Shackle); recipe.AddIngredient(ItemID.Gel, 10); - return new List() { recipe }; + return new List {recipe}; } } -} + + internal class RedHotShackleEffect : GlobalNPC + { + public override void OnHitPlayer(NPC npc, Player target, int damage, bool crit) + { + if (target.HasEquippedAccessory(ModContent.ItemType())) + npc.AddBuff(ModContent.BuffType(), 600); + } + } +} \ No newline at end of file diff --git a/Lib/Util/PlayerUtils.cs b/Lib/Util/PlayerUtils.cs new file mode 100644 index 0000000..b59b2fd --- /dev/null +++ b/Lib/Util/PlayerUtils.cs @@ -0,0 +1,24 @@ +using Decimation.Content; +using Decimation.Lib.Items; +using Terraria; + +namespace Decimation.Lib.Util +{ + public static class PlayerUtils + { + public static DecimationPlayer GetModPlayer(this Player player) + { + return player.GetModPlayer(); + } + + public static void EquipAccessory(this Player player, DecimationAccessory accessory) + { + player.GetModPlayer().EquippedAccessories.Add(accessory.item.type); + } + + public static bool HasEquippedAccessory(this Player player, int accessoryType) + { + return player.GetModPlayer().EquippedAccessories.Contains(accessoryType); + } + } +} \ No newline at end of file