From a19ce2dc1c3948934cc5e6cc63b00bc61728b9f2 Mon Sep 17 00:00:00 2001 From: Jofairden Date: Sat, 23 Sep 2017 16:34:56 +0200 Subject: [PATCH] Put back old CogLord code, ReSharper improvements --- CogLord/NPCs/CogLord.cs | 459 +++++++++++++------------------ CogLord/NPCs/CogLordArm.cs | 73 +++-- CogLord/NPCs/CogLordArmSecond.cs | 73 +++-- CogLord/NPCs/CogLordGun.cs | 132 +++++---- CogLord/NPCs/CogLordHand.cs | 107 ++++--- CogLord/NPCs/CogLordProbe.cs | 20 +- 6 files changed, 437 insertions(+), 427 deletions(-) diff --git a/CogLord/NPCs/CogLord.cs b/CogLord/NPCs/CogLord.cs index 1968e0da..67646f93 100644 --- a/CogLord/NPCs/CogLord.cs +++ b/CogLord/NPCs/CogLord.cs @@ -1,77 +1,78 @@ using System; - +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - namespace Tremor.CogLord.NPCs { + // todo: redo [AutoloadBossHead] public class CogLord : ModNPC { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Cog Lord"); - Main.npcFrameCount[npc.type] = 5; - } - //Framework - public int[] cogHands = new int[2]; + private Vector2 _cogHands = new Vector2(-1, -1); //Bool variables - //bool Ram => ((CogHands.X == -1 && CogHands.Y == -1) || npc.ai[1] == 1); - bool Flag = true; - bool Flag1 = true; - bool Flag2 = true; - bool Rockets = true; + private bool Ram => ((_cogHands.X == -1 && _cogHands.Y == -1) || npc.ai[1] == 1); + + private bool _firstAi = true; + private bool _secondAi = true; + private bool _needCheck; + private bool _flag = true; + private bool _flag1 = true; + private bool _flag2 = true; + private bool _rockets = true; //Float variables - float DistanseBlood = 150f; - float RotationSpeed = 0.3f; - float Rotation; - float LaserRotation = MathHelper.PiOver2; - float NewRotation = MathHelper.PiOver2; + private float _distanseBlood = 150f; + + private float _rotationSpeed = 0.3f; + private float _rotation; + private float _laserRotation = MathHelper.PiOver2; + private float _newRotation = MathHelper.PiOver2; //Int variables - int GetLaserDamage => 30; - int AnimationRate = 6; - int CurrentFrame; - int TimeToAnimation = 6; - int Timer; - int Timer2 = 0; - int ShootType = ProjectileID.HeatRay; - int LaserPosition = 20; - int ShootRate = 10; - int TimeToShoot = 4; - float PreviousRageRotation; + private int GetLaserDamage => 30; + + private int _animationRate = 6; + private int _currentFrame; + private int _timeToAnimation = 6; + private int _timer; + private int _timer2 = 0; + private int _shootType = ProjectileID.HeatRay; + private int _laserPosition = 20; + private int _shootRate = 10; + private int _timeToShoot = 4; + private float _previousRageRotation; //String variables - string LeftHandName = "CogLordHand"; - string RightHandName = "CogLordGun"; + private string _leftHandName = "CogLordHand"; + private string _rightHandName = "CogLordGun"; + public override void SetDefaults() { - npc.width = 86; - npc.height = 124; - + npc.lifeMax = 45000; npc.damage = 25; npc.defense = 5; - npc.lifeMax = 45000; npc.knockBackResist = 0.0f; - - npc.aiStyle = -1; - - npc.boss = true; + npc.width = 86; + npc.height = 124; + npc.aiStyle = 11; npc.noGravity = true; npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath10; - - bossBag = mod.ItemType("CogLordBag"); + npc.boss = true; music = mod.GetSoundSlot(SoundType.Music, "Sounds/Music/Boss6"); + bossBag = mod.ItemType("CogLordBag"); + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cog Lord"); + Main.npcFrameCount[npc.type] = 5; } public override void ScaleExpertStats(int numPlayers, float bossLifeScale) @@ -80,127 +81,165 @@ public override void ScaleExpertStats(int numPlayers, float bossLifeScale) npc.damage = (int)(npc.damage * 0.6f); } - int t; - public override bool PreAI() + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { - if ((t++ % 100) == 0) + spriteBatch.Draw(mod.GetTexture("CogLord/NPCs/CogLordBody"), npc.Center - Main.screenPosition, null, Color.White, 0f, new Vector2(44, -18), 1f, SpriteEffects.None, 0f); + Texture2D drawTexture = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F); + Vector2 drawPos = new Vector2( + npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale, + npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY); + SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); + return false; + } + + public override void AI() + { + npc.TargetClosest(); + if (Main.dayTime) { - NPC.NewNPC((int)((Main.player[npc.target].position.X - 500) + Main.rand.Next(1000)), (int)((Main.player[npc.target].position.Y - 500) + Main.rand.Next(1000)), mod.NPCType("CogLordCog")); + _timer = 0; } - - npc.TargetClosest(true); - - npc.dontTakeDamage = NPC.AnyNPCs(mod.NPCType()); - - if (npc.life < npc.lifeMax * 0.6f && Flag) + if (NPC.AnyNPCs(mod.NPCType("CogLordProbe"))) + { + npc.dontTakeDamage = true; + } + else + npc.dontTakeDamage = false; + if (!Main.expertMode) + npc.position += npc.velocity * 1.7f; + else + npc.position += npc.velocity * 1.02f; + _timer++; + Animation(); + for (int i = 0; i < Main.dust.Length; i++) + { + if (Main.dust[i].type == DustID.Blood && npc.Distance(Main.dust[i].position) < _distanseBlood) + { + Main.dust[i].scale /= 1000000f; + Main.dust[i].active = false; + } + } + foreach (NPC npc2 in Main.npc) + { + if (npc2.type == 36) + { + npc2.active = false; + npc2.life = 0; + npc2.checkDead(); + } + } + foreach (var proj in Main.projectile) + { + if (proj.type == ProjectileID.Skull && Vector2.Distance(proj.Center, npc.Center) < 100f) + { + proj.active = false; + } + } + if (npc.life < npc.lifeMax * 0.6f && _flag) { - Flag = false; + _flag = false; if (Main.expertMode) CogMessage("Low health is detected. Launching support drones."); else CogMessage("Low health is detected. Launching support drone."); - - if (Main.netMode != 1) - { - if (Main.expertMode) - Main.npc[NPC.NewNPC((int)npc.Center.X - 100, (int)npc.Center.Y - 100, mod.NPCType(), 0, npc.whoAmI, 0, 200)].netUpdate = true; - Main.npc[NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType(), 0, npc.whoAmI, 0, 200)].netUpdate = true; - } + if (Main.expertMode) + NPC.NewNPC((int)npc.Center.X - 100, (int)npc.Center.Y - 100, mod.NPCType("CogLordProbe"), 0, npc.whoAmI, 0, 200); + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogLordProbe"), 0, npc.whoAmI, 0, 200); } - if (npc.life < npc.lifeMax * 0.4f && Flag1) + if (npc.life < npc.lifeMax * 0.4f && _flag1) { - Flag1 = false; + _flag1 = false; if (Main.expertMode) CogMessage("Low health is detected. Launching support drones."); else CogMessage("Low health is detected. Launching support drone."); - - if (Main.netMode != 1) - { - if (Main.expertMode) - Main.npc[NPC.NewNPC((int)npc.Center.X - 100, (int)npc.Center.Y - 100, mod.NPCType(), 0, npc.whoAmI, 0, 200)].netUpdate = true; - Main.npc[NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType(), 0, npc.whoAmI, 0, 200)].netUpdate = true; - } + if (Main.expertMode) + NPC.NewNPC((int)npc.Center.X - 100, (int)npc.Center.Y - 100, mod.NPCType("CogLordProbe"), 0, npc.whoAmI, 0, 200); + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogLordProbe"), 0, npc.whoAmI, 0, 200); } - if (npc.life < npc.lifeMax * 0.2f && Flag2) + if (npc.life < npc.lifeMax * 0.2f && _flag2) { - Flag2 = false; + _flag2 = false; if (Main.expertMode) CogMessage("Low health is detected. Launching support drones."); else CogMessage("Low health is detected. Launching support drone."); - - if (Main.netMode != 1) - { - if (Main.expertMode) - Main.npc[NPC.NewNPC((int)npc.Center.X - 100, (int)npc.Center.Y - 100, mod.NPCType(), 0, npc.whoAmI, 0, 200)].netUpdate = true; - Main.npc[NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType(), 0, npc.whoAmI, 0, 200)].netUpdate = true; - } + if (Main.expertMode) + NPC.NewNPC((int)npc.Center.X - 100, (int)npc.Center.Y - 100, mod.NPCType("CogLordProbe"), 0, npc.whoAmI, 0, 200); + NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogLordProbe"), 0, npc.whoAmI, 0, 200); } - - // First update, spawn Arms. - if(npc.ai[0] == 0) + if (_firstAi) { - if (Main.netMode != 1) + _firstAi = false; + } + else + { + if (_secondAi) { MakeHands(); - /*CheckHands();*/ - - //if (CogHands.Y != -1) - // Main.npc[(int)CogHands.Y].ai[1] = 1; + _secondAi = false; + _needCheck = true; } - npc.ai[0] = 1; } - else if(npc.ai[0] == 1) + if (!Ram) { - NormalMovement(); + if (_needCheck) + CheckHands(); + if (_cogHands.Y != -1 && _needCheck) + { + Main.npc[(int)_cogHands.Y].localAI[3] = 0; + } } - - /*if(Ram) + else { - if (Rockets) + if (_rockets) { - Rockets = false; + _rockets = false; CogMessage("Protocol 10 is activated: Preparing for rocket storm."); } - //Rotation += RotationSpeed; - //npc.rotation = Rotation; + npc.frame = GetFrame(5); + _rotation += _rotationSpeed; + npc.rotation = _rotation; if ((int)(Main.time % 120) == 0) { for (int k = 0; k < ((Main.expertMode) ? 2 : 1); k++) { - Vector2 Velocity = Helper.VelocityToPoint(npc.Center, Helper.RandomPointInArea(new Vector2(Main.player[Main.myPlayer].Center.X - 10, Main.player[Main.myPlayer].Center.Y - 10), new Vector2(Main.player[Main.myPlayer].Center.X + 20, Main.player[Main.myPlayer].Center.Y + 20)), 20); - int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, Velocity.X, Velocity.Y, 134, GetLaserDamage * ((Main.expertMode) ? 3 : 2), 1f); + Vector2 velocity = Helper.VelocityToPoint(npc.Center, Helper.RandomPointInArea(new Vector2(Main.player[Main.myPlayer].Center.X - 10, Main.player[Main.myPlayer].Center.Y - 10), new Vector2(Main.player[Main.myPlayer].Center.X + 20, Main.player[Main.myPlayer].Center.Y + 20)), 20); + int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, 134, GetLaserDamage * ((Main.expertMode) ? 3 : 2), 1f); Main.projectile[i].hostile = true; Main.projectile[i].tileCollide = true; Main.projectile[i].friendly = false; } } - - CheckHands(); - if (CogHands.Y != -1) - Main.npc[(int)CogHands.Y].ai[1] = 0; + if (_needCheck) + CheckHands(); + if (_cogHands.Y != -1 && _needCheck) + { + Main.npc[(int)_cogHands.Y].localAI[3] = 1; + } } - if (Timer == 400) + if (_timer == 400) { CogMessage("Protocol 11 is activated: Clockwork laser cutter is being enabled."); } - if (Timer >= 500 && Timer < 800) + if (_timer >= 500 && _timer < 800) { - PreviousRageRotation = 0f; + _previousRageRotation = 0f; if (Main.netMode != 1) { - LaserRotation += 0.01f; - if (--TimeToShoot <= 0) + _laserRotation += 0.01f; + if (--_timeToShoot <= 0) { - TimeToShoot = ShootRate; - var ShootPos = npc.Center + new Vector2(0, 17); - var ShootVel = new Vector2(0, 7).RotatedBy(LaserRotation); + _timeToShoot = _shootRate; + var shootPos = npc.Center + new Vector2(0, 17); + var shootVel = new Vector2(0, 7).RotatedBy(_laserRotation); int[] i = { - Projectile.NewProjectile(ShootPos, ShootVel, ShootType, GetLaserDamage, 1f), - Projectile.NewProjectile(ShootPos, ShootVel.RotatedBy(MathHelper.PiOver2), ShootType, GetLaserDamage, 1f), - Projectile.NewProjectile(ShootPos, ShootVel.RotatedBy(MathHelper.Pi), ShootType, GetLaserDamage, 1f), - Projectile.NewProjectile(ShootPos, ShootVel.RotatedBy(-MathHelper.PiOver2), ShootType, GetLaserDamage, 1f) + Projectile.NewProjectile(shootPos, shootVel, _shootType, GetLaserDamage, 1f), + Projectile.NewProjectile(shootPos, shootVel.RotatedBy(MathHelper.PiOver2), _shootType, GetLaserDamage, 1f), + Projectile.NewProjectile(shootPos, shootVel.RotatedBy(MathHelper.Pi), _shootType, GetLaserDamage, 1f), + Projectile.NewProjectile(shootPos, shootVel.RotatedBy(-MathHelper.PiOver2), _shootType, GetLaserDamage, 1f) }; for (int l = 0; l < i.Length; l++) { @@ -210,178 +249,88 @@ public override bool PreAI() } } } - if (Timer >= 800 && Timer < 1200) + if (_timer >= 800 && _timer < 1200) { npc.velocity.X *= 2.00f; npc.velocity.Y *= 2.00f; - Vector2 Vector = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height * 0.5f)); + Vector2 vector = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height * 0.5f)); { - float CLRad = (float)Math.Atan2((Vector.Y) - (Main.player[npc.target].position.Y + (Main.player[npc.target].height * 0.5f)), (Vector.X) - (Main.player[npc.target].position.X + (Main.player[npc.target].width * 0.5f))); - npc.velocity.X = (float)(Math.Cos(CLRad) * 4) * -1; - npc.velocity.Y = (float)(Math.Sin(CLRad) * 4) * -1; + float clRad = (float)Math.Atan2((vector.Y) - (Main.player[npc.target].position.Y + (Main.player[npc.target].height * 0.5f)), (vector.X) - (Main.player[npc.target].position.X + (Main.player[npc.target].width * 0.5f))); + npc.velocity.X = (float)(Math.Cos(clRad) * 4) * -1; + npc.velocity.Y = (float)(Math.Sin(clRad) * 4) * -1; } } - if (Timer == 1100) + if (_timer == 1100) { CogMessage("Protocol 12 is activated: Summoning gears."); } - if (Timer > 1200 && Timer < 1700) + if (_timer > 1200 && _timer < 1700) { if ((int)(Main.time % 15) == 0) NPC.NewNPC((int)((Main.player[npc.target].position.X - 500) + Main.rand.Next(1000)), (int)((Main.player[npc.target].position.Y - 500) + Main.rand.Next(1000)), mod.NPCType("GogLordGog")); } - if (Timer == 1600) + if (_timer == 1600) { CogMessage("Protocol 13 is activated: Rocket attack incoming."); } - if (Timer >= 1700 && Timer < 1775) + if (_timer >= 1700 && _timer < 1775) { if (Main.rand.NextBool(3)) { - var ShootPos = Main.player[npc.target].position + new Vector2(Main.rand.Next(-1000, 1000), -1000); - var ShootVel = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(15f, 20f)); - int i = Projectile.NewProjectile(ShootPos, ShootVel, 134, GetLaserDamage * ((Main.expertMode) ? 3 : 2), 1f); + var shootPos = Main.player[npc.target].position + new Vector2(Main.rand.Next(-1000, 1000), -1000); + var shootVel = new Vector2(Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(15f, 20f)); + int i = Projectile.NewProjectile(shootPos, shootVel, 134, GetLaserDamage * ((Main.expertMode) ? 3 : 2), 1f); Main.projectile[i].hostile = true; Main.projectile[i].tileCollide = true; Main.projectile[i].friendly = false; } } - if (Timer > 1775) + if (_timer > 1775) { - Rockets = true; - Timer = 0; - }*/ - - return false; + _rockets = true; + _timer = 0; + } + _rotation = 0; } - protected void NormalMovement() + public void CheckHands() { - Player player = Main.player[npc.target]; - - npc.rotation = npc.velocity.X / 15f; - - int maxYSpeed = 4; - float yAcceleration = 0.02F; - int maxXSpeed = 10; - float xAcceleration = 0.05F; - - if (npc.position.Y > player.position.Y - 250f) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y * 0.98f; - npc.velocity.Y = npc.velocity.Y - yAcceleration; - } - else if (npc.position.Y < player.position.Y - 250f) - { - if (npc.velocity.Y < 0f) - npc.velocity.Y = npc.velocity.Y * 0.98f; - npc.velocity.Y = npc.velocity.Y + yAcceleration; - } - if (npc.position.X + (npc.width / 2) > player.position.X + (player.width / 2)) - { - if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X * 0.98f; - npc.velocity.X = npc.velocity.X - xAcceleration; - } - if (npc.position.X + (npc.width / 2) < player.position.X + (player.width / 2)) - { - if (npc.velocity.X < 0f) - npc.velocity.X = npc.velocity.X * 0.98f; - npc.velocity.X = npc.velocity.X + xAcceleration; - } + if (_cogHands.X != -1) + if (!((Main.npc[(int)_cogHands.X].type == mod.NPCType(_leftHandName) && Main.npc[(int)_cogHands.X].ai[1] == npc.whoAmI) && Main.npc[(int)_cogHands.X].active)) + _cogHands.X = -1; + if (_cogHands.Y != -1) + if (!((Main.npc[(int)_cogHands.Y].type == mod.NPCType(_rightHandName) && Main.npc[(int)_cogHands.Y].ai[1] == npc.whoAmI) && Main.npc[(int)_cogHands.Y].active)) + _cogHands.Y = -1; + } - npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -maxXSpeed, maxXSpeed); - npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -maxYSpeed, maxYSpeed); - /* - this.ai[2] += 1f; - if (this.ai[2] >= 800f) - { - this.ai[2] = 0f; - this.ai[1] = 1f; - this.TargetClosest(true); - this.netUpdate = true; - } - this.rotation = this.velocity.X / 15f; - float num167 = 0.02f; - float num168 = 2f; - float num169 = 0.05f; - float num170 = 8f; - if (Main.expertMode) - { - num167 = 0.03f; - num168 = 4f; - num169 = 0.07f; - num170 = 9.5f; - }*/ + public void MakeHands() + { + _cogHands.X = NPC.NewNPC((int)npc.Center.X - 50, (int)npc.Center.Y, mod.NPCType(_leftHandName), 0, 1, npc.whoAmI); + _cogHands.Y = NPC.NewNPC((int)npc.Center.X + 50, (int)npc.Center.Y, mod.NPCType(_rightHandName), 0, -1, npc.whoAmI); } - public override void FindFrame(int frameHeight) + public void Animation() { - if(npc.ai[0] == 2) - npc.frame.Y = 4 * frameHeight; - else if(npc.frameCounter++ >= 8) + if (--_timeToAnimation <= 0) { - npc.frame.Y = (npc.frame.Y + frameHeight) % ((Main.npcFrameCount[npc.type]-1) * frameHeight); - npc.frameCounter = 0; + if (++_currentFrame > 4) + _currentFrame = 1; + _timeToAnimation = _animationRate; + npc.frame = GetFrame(_currentFrame); } } - public void MakeHands() + private Rectangle GetFrame(int number) { - // Create the Left Hand. - cogHands[0] = NPC.NewNPC((int)npc.Center.X - 50, (int)npc.Center.Y, mod.NPCType(LeftHandName), 0, npc.whoAmI); - // Create the Left Arm parts. - int upperLeftArm = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType()); - int lowerLeftArm = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType()); - - // Set the targets of the Upper Left Arm. - Main.npc[upperLeftArm].ai[0] = npc.whoAmI; - Main.npc[upperLeftArm].ai[1] = lowerLeftArm; - // Set the targets of the Lower Left Arm. - Main.npc[lowerLeftArm].ai[0] = cogHands[0]; - Main.npc[lowerLeftArm].ai[1] = upperLeftArm; - - // Create the Right Hand. - cogHands[1] = NPC.NewNPC((int)npc.Center.X + 50, (int)npc.Center.Y, mod.NPCType(RightHandName), 0, npc.whoAmI); - // Create the Right Arm parts. - int upperRightArm = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType()); - int lowerRightArm = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType()); - - // Set the targets of the Upper Right Arm. - Main.npc[upperRightArm].ai[0] = npc.whoAmI; - Main.npc[upperRightArm].ai[1] = lowerRightArm; - // Set the targets of the Lower Right Arm. - Main.npc[lowerRightArm].ai[0] = cogHands[1]; - Main.npc[lowerRightArm].ai[1] = upperRightArm; - - // Make sure everything is correctly updated over the net. - Main.npc[upperLeftArm].netUpdate = true; - Main.npc[lowerLeftArm].netUpdate = true; - - Main.npc[upperRightArm].netUpdate = true; - Main.npc[lowerRightArm].netUpdate = true; - - Main.npc[cogHands[0]].netUpdate = true; - Main.npc[cogHands[1]].netUpdate = true; + return new Rectangle(0, npc.frame.Height * (number - 1), npc.frame.Width, npc.frame.Height); } - /*public void CheckHands() - { - if (CogHands.X != -1) - if (Main.npc[(int)CogHands.X].type != mod.NPCType(LeftHandName) || Main.npc[(int)CogHands.X].ai[0] != npc.whoAmI || !Main.npc[(int)CogHands.X].active) - CogHands.X = -1; - - if (CogHands.Y != -1) - if (Main.npc[(int)CogHands.Y].type != mod.NPCType(RightHandName) || Main.npc[(int)CogHands.Y].ai[0] != npc.whoAmI || !Main.npc[(int)CogHands.Y].active) - CogHands.Y = -1; - }*/ - public void CogMessage(string Message) + public void CogMessage(string message) { - string Text = "[CL-AI]: " + Message; + string text = "[CL-AI]: " + message; if (Main.netMode != 2) { - Main.NewText("[CL-AI]: " + Message, 208, 137, 55); + Main.NewText("[CL-AI]: " + message, 208, 137, 55); } } public override void NPCLoot() @@ -422,21 +371,5 @@ public override void NPCLoot() Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("BrassNugget"), Main.rand.Next(18, 32)); } } - - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) - { - spriteBatch.Draw(mod.GetTexture("CogLord/NPCs/CogLordBody"), npc.Center - Main.screenPosition, null, Color.White, 0f, new Vector2(44, -18), 1f, SpriteEffects.None, 0f); - - Texture2D drawTexture = Main.npcTexture[npc.type]; - Vector2 origin = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F); - Vector2 drawPos = new Vector2( - npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale, - npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY); - SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); - return false; - } } -} - - \ No newline at end of file +} \ No newline at end of file diff --git a/CogLord/NPCs/CogLordArm.cs b/CogLord/NPCs/CogLordArm.cs index 6360a0cb..db3915d1 100644 --- a/CogLord/NPCs/CogLordArm.cs +++ b/CogLord/NPCs/CogLordArm.cs @@ -1,64 +1,77 @@ -using Terraria; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Microsoft.Xna.Framework; - namespace Tremor.CogLord.NPCs { public class CogLordArm : ModNPC { - /// The Cog Lord boss NPC. Found using npc.ai[0] - NPC cogLord => Main.npc[(int)npc.ai[0]]; - - /// The Lower Arm npc for the corresponding arm side. Found using npc.ai[1] - NPC lowerArm => Main.npc[(int)npc.ai[1]]; - public override void SetStaticDefaults() { Main.npcFrameCount[npc.type] = 2; } + //Int variables + private int _animationRate = 6; + private int _timeToAnimation = 6; + private int _currentFrame; + + //Float variables + private float _dist = 150; + public override void SetDefaults() { - npc.width = 104; - npc.height = 38; - npc.lifeMax = 1; npc.knockBackResist = 0.5f; - - npc.aiStyle = -1; - + npc.width = 104; + npc.height = 38; + npc.aiStyle = 0; npc.noGravity = true; npc.noTileCollide = true; npc.dontTakeDamage = true; - npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; + npc.value = Item.buyPrice(0, 0, 5, 0); } - public override bool PreAI() + public override void AI() { - if (cogLord.active && cogLord.type == mod.NPCType()) + if (--_timeToAnimation <= 0) { - npc.Center = Vector2.Lerp(npc.Center, Helper.CenterPoint(cogLord.Center, lowerArm.Center), 0.2F); - npc.rotation = MathHelper.Lerp(npc.rotation, npc.rotation = Helper.rotateBetween2Points(cogLord.Center, lowerArm.Center), 0.2F); + if (++_currentFrame > 2) + _currentFrame = 1; + _timeToAnimation = _animationRate; + npc.frame = GetFrame(_currentFrame); } - else - npc.active = false; - return false; + if (Main.npc[(int)npc.ai[0]].type == mod.NPCType("CogLordArmSecond") && Main.npc[(int)npc.ai[0]].active) + { + npc.Center = Helper.CenterPoint(Main.npc[(int)npc.ai[3]].Center, Main.npc[(int)npc.ai[0]].Center); + npc.rotation = Helper.rotateBetween2Points(Main.npc[(int)npc.ai[3]].Center, Main.npc[(int)npc.ai[0]].Center); + if (npc.ai[1] == 0) npc.spriteDirection = -1; + else npc.spriteDirection = 1; + } + else + npc.life = -1; } - public override void FindFrame(int frameHeight) + private Rectangle GetFrame(int number) { - if(npc.frameCounter++ >= 15) - { - npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); - npc.frameCounter = 0; - } + return new Rectangle(0, npc.frame.Height * (number - 1), npc.frame.Width, npc.frame.Height); + } - npc.spriteDirection = npc.direction; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D drawTexture = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F); + Vector2 drawPos = new Vector2( + npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale, + npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY); + SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); + return false; } } } \ No newline at end of file diff --git a/CogLord/NPCs/CogLordArmSecond.cs b/CogLord/NPCs/CogLordArmSecond.cs index d6f3f99a..7a739adf 100644 --- a/CogLord/NPCs/CogLordArmSecond.cs +++ b/CogLord/NPCs/CogLordArmSecond.cs @@ -1,63 +1,78 @@ -using Terraria; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Microsoft.Xna.Framework; - namespace Tremor.CogLord.NPCs { public class CogLordArmSecond : ModNPC { - /// The Hand (end) of the corresponding arm side. Found using npc.ai[0] - NPC targetHand => Main.npc[(int)npc.ai[0]]; - /// The Upper Arm npc for the corresponding arm side. Found using npc.ai[1] - NPC upperArm => Main.npc[(int)npc.ai[1]]; - public override void SetStaticDefaults() { Main.npcFrameCount[npc.type] = 2; } + //Int variables + private int _animationRate = 6; + + private int _currentFrame; + private int _timeToAnimation = 6; + + //Float variables + private float _dist = 150; + public override void SetDefaults() { - npc.width = 112; - npc.height = 34; - npc.lifeMax = 1; npc.knockBackResist = 0.5f; - - npc.aiStyle = -1; - + npc.width = 112; + npc.height = 34; + npc.aiStyle = 0; npc.noGravity = true; npc.noTileCollide = true; npc.dontTakeDamage = true; - npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; + npc.value = Item.buyPrice(0, 0, 5, 0); } - public override bool PreAI() + public override void AI() { - if (targetHand.active && (targetHand.type == mod.NPCType() || targetHand.type == mod.NPCType())) + if (--_timeToAnimation <= 0) { - npc.Center = Vector2.Lerp(npc.Center, Helper.CenterPoint(Helper.CenterPoint(upperArm.Center, targetHand.Center), targetHand.Center), 0.2F); - npc.rotation = MathHelper.Lerp(npc.rotation, Helper.rotateBetween2Points(upperArm.Center, targetHand.Center), 0.2F); + if (++_currentFrame > 2) + _currentFrame = 1; + _timeToAnimation = _animationRate; + npc.frame = GetFrame(_currentFrame); } - else - npc.active = false; - return false; + if ((Main.npc[(int)npc.ai[0]].type == mod.NPCType("CogLordGun") || Main.npc[(int)npc.ai[0]].type == mod.NPCType("CogLordHand")) && Main.npc[(int)npc.ai[0]].active) + { + npc.Center = Helper.CenterPoint(Helper.CenterPoint(Main.npc[(int)npc.ai[3]].Center, Main.npc[(int)npc.ai[0]].Center), Main.npc[(int)npc.ai[0]].Center); + npc.rotation = Helper.rotateBetween2Points(Main.npc[(int)npc.ai[3]].Center, Main.npc[(int)npc.ai[0]].Center); + if (npc.ai[1] == 0) npc.spriteDirection = -1; + else npc.spriteDirection = 1; + } + else + npc.life = -1; } - public override void FindFrame(int frameHeight) + private Rectangle GetFrame(int number) { - if (npc.frameCounter++ >= 15) - { - npc.frame.Y = (npc.frame.Y + frameHeight) % (Main.npcFrameCount[npc.type] * frameHeight); - npc.frameCounter = 0; - } + return new Rectangle(0, npc.frame.Height * (number - 1), npc.frame.Width, npc.frame.Height); + } - npc.spriteDirection = npc.direction; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D drawTexture = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F); + Vector2 drawPos = new Vector2( + npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale, + npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY); + SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); + return false; } } } \ No newline at end of file diff --git a/CogLord/NPCs/CogLordGun.cs b/CogLord/NPCs/CogLordGun.cs index 29aed64b..2440bde9 100644 --- a/CogLord/NPCs/CogLordGun.cs +++ b/CogLord/NPCs/CogLordGun.cs @@ -1,9 +1,9 @@ -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - + using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; namespace Tremor.CogLord.NPCs { @@ -12,98 +12,126 @@ namespace Tremor.CogLord.NPCs * npc.ai[1] = State manager. * npc.ai[2] = (Shoot) timer. */ - public class CogLordGun : ModNPC { - NPC cogLord => Main.npc[(int)npc.ai[0]]; - public override void SetStaticDefaults() { DisplayName.SetDefault("Cog Lord Gun"); } - const int shootRate = 120; - const int ShootDamage = 20; - const float ShootKN = 1.0f; - const int ShootType = 88; - const float ShootSpeed = 5; - const int ShootCount = 10; - const int spread = 45; - const float spreadMult = 0.045f; - const float MaxDist = 250f; + private const int ShootRate = 120; + private const int ShootDamage = 20; + private const float ShootKn = 1.0f; + private const int ShootType = 88; + private const float ShootSpeed = 5; + private const int ShootCount = 10; + private const int Spread = 45; + private const float SpreadMult = 0.045f; + private const float MaxDist = 250f; + + private int _timeToShoot = ShootRate; public override void SetDefaults() { - npc.width = 88; - npc.height = 46; - + npc.lifeMax = 20000; npc.damage = 80; npc.defense = 20; - npc.lifeMax = 20000; npc.knockBackResist = 0f; - + npc.width = 88; + npc.height = 46; npc.aiStyle = 12; - npc.noGravity = true; npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - npc.value = Item.buyPrice(0, 0, 5, 0); } - + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CogLordGun"), 1f); + + } + } + + private bool _firstAi = true; public override void AI() { - if (Main.player[cogLord.target].active) + if (_firstAi) { - // If the boss is not 'ramming'. - if (npc.ai[1] == 1) + _firstAi = false; + MakeArms(); + } + if (Main.npc[(int)npc.ai[1]].type == mod.NPCType("CogLord") && Main.npc[(int)npc.ai[1]].active) + if (Main.player[Main.npc[(int)npc.ai[1]].target].active) { - npc.rotation = Helper.rotateBetween2Points(npc.Center, Main.player[cogLord.target].Center); - if (Main.netMode != 1 && npc.ai[2]++ >= shootRate) + if (npc.localAI[3] == 0f) { - Shoot(); - npc.ai[2] = 0; + npc.rotation = Helper.rotateBetween2Points(npc.Center, Main.player[Main.npc[(int)npc.ai[1]].target].Center); + if (--_timeToShoot <= 0) Shoot(); } } + if (NPC.AnyNPCs(mod.NPCType("CogLordProbe"))) + { + npc.dontTakeDamage = true; } - - npc.dontTakeDamage = NPC.AnyNPCs(mod.NPCType()); - - Vector2 CogLordCenter = cogLord.Center; - Vector2 Distance = npc.Center - CogLordCenter; - if (Distance.Length() >= MaxDist) + else { - Distance.Normalize(); - Distance *= MaxDist; - npc.Center = CogLordCenter + Distance; + npc.dontTakeDamage = false; } + Vector2 cogLordCenter = Main.npc[(int)npc.ai[1]].Center; + Vector2 distance = npc.Center - cogLordCenter; + if (distance.Length() >= MaxDist) + { + distance.Normalize(); + distance *= MaxDist; + npc.Center = cogLordCenter + distance; + } + } + + private void MakeArms() + { + int arm = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogLordArm"), 0, 9999, 1, 1, npc.ai[1]); + int arm2 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogLordArmSecond"), 0, npc.whoAmI, 0, 1, arm); + Main.npc[arm].ai[0] = arm2; } - void Shoot() + private void Shoot() { - if (cogLord.target != -1) + _timeToShoot = ShootRate; + if (Main.npc[(int)npc.ai[1]].target != -1) { - Vector2 velocity = Helper.VelocityToPoint(npc.Center, Main.player[cogLord.target].Center, ShootSpeed); + Vector2 velocity = Helper.VelocityToPoint(npc.Center, Main.player[Main.npc[(int)npc.ai[1]].target].Center, ShootSpeed); for (int l = 0; l < 2; l++) { - velocity.X = velocity.X + Main.rand.Next(-spread, spread + 1) * spreadMult; - velocity.Y = velocity.Y + Main.rand.Next(-spread, spread + 1) * spreadMult; - int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKN); + velocity.X = velocity.X + Main.rand.Next(-Spread, Spread + 1) * SpreadMult; + velocity.Y = velocity.Y + Main.rand.Next(-Spread, Spread + 1) * SpreadMult; + int i = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, ShootType, ShootDamage, ShootKn); Main.projectile[i].hostile = true; Main.projectile[i].friendly = false; } } } - public override bool PreNPCLoot() => false; - public override bool CheckActive() => !(cogLord.type == mod.NPCType() && cogLord.active); + public override bool PreNPCLoot() + { + npc.aiStyle = -1; + npc.ai[1] = -1; + return false; + } - public override void HitEffect(int hitDirection, double damage) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - if (npc.life <= 0) - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CogLordGun"), 1f); + Texture2D drawTexture = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F); + Vector2 drawPos = new Vector2( + npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale, + npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY); + SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); + return false; } } } \ No newline at end of file diff --git a/CogLord/NPCs/CogLordHand.cs b/CogLord/NPCs/CogLordHand.cs index 312943d8..b9bc56bc 100644 --- a/CogLord/NPCs/CogLordHand.cs +++ b/CogLord/NPCs/CogLordHand.cs @@ -1,7 +1,6 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; - using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -15,10 +14,6 @@ namespace Tremor.CogLord.NPCs public class CogLordHand : ModNPC { - NPC cogLord => Main.npc[(int)npc.ai[0]]; - - const float MaxDist = 250f; - public override void SetStaticDefaults() { DisplayName.SetDefault("Cog Lord Hand"); @@ -27,74 +22,100 @@ public override void SetStaticDefaults() public override void SetDefaults() { - npc.width = 44; - npc.height = 84; - + npc.lifeMax = 20000; npc.damage = 80; npc.defense = 20; - npc.lifeMax = 20000; npc.knockBackResist = 0f; - + npc.width = 44; + npc.height = 84; npc.aiStyle = 12; - npc.noGravity = true; npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; - npc.value = Item.buyPrice(0, 0, 5, 0); } - + + private const float MaxDist = 250f; + private bool _firstAi = true; + private int _timer; + public override void AI() { - npc.dontTakeDamage = NPC.AnyNPCs(mod.NPCType()); - - if (npc.ai[1] == 0) + _timer++; + if (_firstAi) + { + _firstAi = false; + MakeArms(); + } + if (NPC.AnyNPCs(mod.NPCType("CogLordProbe"))) { + npc.dontTakeDamage = true; + } + else + npc.dontTakeDamage = false; + if (_timer < 1000) + { + npc.frame = GetFrame(1); npc.damage = 80; - - if (npc.ai[2]++ >= 1000) - { - npc.ai[1] = 1; - npc.ai[2] = 0; - } } - else if (npc.ai[1] == 1) + if (_timer >= 1000 && _timer < 1500) { + npc.frame = GetFrame(2); npc.dontTakeDamage = true; npc.damage = 120; - - if (npc.ai[2]++ >= 500) - { - npc.ai[1] = 0; - npc.ai[2] = 0; - } - } - - Vector2 Distance = npc.Center - cogLord.Center; - if (Distance.Length() >= MaxDist) + } + if (_timer > 1500) + { + _timer = 0; + } + Vector2 cogLordCenter = Main.npc[(int)npc.ai[1]].Center; + Vector2 distance = npc.Center - cogLordCenter; + if (distance.Length() >= MaxDist) { - Distance.Normalize(); - Distance *= MaxDist; - npc.Center = cogLord.Center + Distance; + distance.Normalize(); + distance *= MaxDist; + npc.Center = cogLordCenter + distance; } } - public override void FindFrame(int frameHeight) + private Rectangle GetFrame(int number) { - if (npc.ai[1] == 0) - npc.frame.Y = 0; - if (npc.ai[1] == 1) - npc.frame.Y = frameHeight; + return new Rectangle(0, npc.frame.Height * (number - 1), npc.frame.Width, npc.frame.Height); } public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) + { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/CogLordHand"), 1f); + } } - public override bool PreNPCLoot() => false; + private void MakeArms() + { + int arm = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogLordArm"), 0, 9999, 1, 1, npc.ai[1]); + int arm2 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogLordArmSecond"), 0, npc.whoAmI, 0, 1, arm); + Main.npc[arm].ai[0] = arm2; + } + + public override bool PreNPCLoot() + { + npc.aiStyle = -1; + npc.ai[1] = -1; + return false; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D drawTexture = Main.npcTexture[npc.type]; + Vector2 origin = new Vector2((drawTexture.Width / 2) * 0.5F, (drawTexture.Height / Main.npcFrameCount[npc.type]) * 0.5F); + Vector2 drawPos = new Vector2( + npc.position.X - Main.screenPosition.X + (npc.width / 2) - (Main.npcTexture[npc.type].Width / 2) * npc.scale / 2f + origin.X * npc.scale, + npc.position.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + origin.Y * npc.scale + npc.gfxOffY); + SpriteEffects effects = npc.spriteDirection == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + spriteBatch.Draw(drawTexture, drawPos, npc.frame, Color.White, npc.rotation, origin, npc.scale, effects, 0); + return false; + } } } \ No newline at end of file diff --git a/CogLord/NPCs/CogLordProbe.cs b/CogLord/NPCs/CogLordProbe.cs index e96b6354..aeb5384c 100644 --- a/CogLord/NPCs/CogLordProbe.cs +++ b/CogLord/NPCs/CogLordProbe.cs @@ -1,10 +1,9 @@ -using Terraria; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - namespace Tremor.CogLord.NPCs { public class CogLordProbe : ModNPC @@ -30,8 +29,9 @@ public override void SetDefaults() npc.value = Item.buyPrice(0, 1, 0, 0); } - int ShootRate = 4; - int TimeToShoot = 4; + private int _shootRate = 4; + private int _timeToShoot = 4; + public override void AI() { npc.position += npc.velocity * 1.7f; @@ -40,12 +40,12 @@ public override void AI() { npc.Center = Main.npc[(int)npc.ai[0]].Center; } - if (--TimeToShoot <= 0) + if (--_timeToShoot <= 0) { - TimeToShoot = ShootRate; + _timeToShoot = _shootRate; NPC parent = Main.npc[NPC.FindFirstNPC(mod.NPCType("CogLord"))]; - Vector2 Velocity = Helper.VelocityToPoint(npc.Center, parent.Center, 20); - int k = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, Velocity.X, Velocity.Y, mod.ProjectileType("CogLordLaser"), 100, 1f); + Vector2 velocity = Helper.VelocityToPoint(npc.Center, parent.Center, 20); + int k = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, mod.ProjectileType("CogLordLaser"), 100, 1f); Main.projectile[k].friendly = false; Main.projectile[k].tileCollide = false; Main.projectile[k].hostile = true;