public void playShotVFX(Vector2 origin, Vector2 direction) { transform.position = origin; transform.rotation = direction.ToRotation(); vfx.Play(); firedRay.enabled = true; Callback.DoLerp((float l) => { Color rayColor = Color.Lerp(Color.white, Color.black, l); rayColor.a = 1 - l; mesh.colors = new Color[] { rayColor, rayColor, rayColor, rayColor }; }, rayDuration, this).FollowedBy(() => firedRay.enabled = false, this); }
/*public void Dusts() * { * Main.PlaySound(SoundID.NPCKilled, projectile.Center, 6); * for (int index1 = 0; index1 < 15; ++index1) * { * int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); * Main.dust[index2].position = new Vector2((float)(projectile.width / 2), 0.0f).RotatedBy(6.28318548202515 * Main.rand.NextDouble(), new Vector2()) * (float)Main.rand.NextDouble() + projectile.Center; * } * for (int index1 = 0; index1 < 50; ++index1) * { * int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0.0f, 0.0f, 0, new Color(), 2.5f); * Main.dust[index2].position = new Vector2((float)(projectile.width / 2), 0.0f).RotatedBy(6.28318548202515 * Main.rand.NextDouble(), new Vector2()) * (float)Main.rand.NextDouble() + projectile.Center; * Main.dust[index2].noGravity = true; * Dust dust1 = Main.dust[index2]; * dust1.velocity = dust1.velocity * 1f; * int index3 = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0.0f, 0.0f, 100, new Color(), 1.5f); * Main.dust[index3].position = new Vector2((float)(projectile.width / 2), 0.0f).RotatedBy(6.28318548202515 * Main.rand.NextDouble(), new Vector2()) * (float)Main.rand.NextDouble() + projectile.Center; * Dust dust2 = Main.dust[index3]; * dust2.velocity = dust2.velocity * 1f; * Main.dust[index3].noGravity = true; * } * * for (int i = 0; i < 50; i++) * { * int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 3f); * Main.dust[dust].velocity *= 1.4f; * } * * for (int i = 0; i < 50; i++) * { * int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3.5f); * Main.dust[dust].noGravity = true; * Main.dust[dust].velocity *= 7f; * dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1.5f); * Main.dust[dust].velocity *= 3f; * } * * for (int index1 = 0; index1 < 100; ++index1) * { * int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, new Color(), 2f); * Main.dust[index2].noGravity = true; * Main.dust[index2].velocity *= 21f * projectile.scale; * Main.dust[index2].noLight = true; * int index3 = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, new Color(), 1f); * Main.dust[index3].velocity *= 12f; * Main.dust[index3].noGravity = true; * Main.dust[index3].noLight = true; * } * * for (int i = 0; i < 100; i++) * { * int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, Main.rand.NextFloat(2f, 3.5f)); * if (Main.rand.Next(3) == 0) * Main.dust[d].noGravity = true; * Main.dust[d].velocity *= Main.rand.NextFloat(9f, 12f); * Main.dust[d].position = projectile.Center; * } * }*/ public override void Kill(int timeLeft) { int ai0 = (int)projectile.ai[0]; //core int ai1 = (int)projectile.ai[1]; //socket if (ai1 > -1 && ai1 < Main.maxNPCs && Main.npc[ai1].active && Main.npc[ai1].type == NPCID.MoonLordHand && Main.npc[ai1].ai[3] == ai0 && Main.npc[ai0].ai[0] != 2f) // && EModeGlobalNPC.masoStateML == 0) //valid { if (!Main.dedServ && Main.LocalPlayer.active) { Main.LocalPlayer.GetModPlayer <FargoPlayer>().Screenshake = 30; } if (Main.netMode != NetmodeID.MultiplayerClient) //chain explosions { //perpendicular /*Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<MoonLordSunBlast>(), * projectile.damage, projectile.knockBack, projectile.owner, projectile.velocity.ToRotation() + MathHelper.PiOver2, 5); * Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType<MoonLordSunBlast>(), * projectile.damage, projectile.knockBack, projectile.owner, projectile.velocity.ToRotation() - MathHelper.PiOver2, 5);*/ const int max = 4; //spread for (int i = 0; i < max; i++) { Vector2 offset = projectile.width / 2 * Vector2.UnitX.RotatedBy(Math.PI * 2 / max * i); Projectile.NewProjectile(projectile.Center + Main.rand.NextVector2Circular(projectile.width / 2, projectile.height / 2), Vector2.Zero, ModContent.ProjectileType <MoonLordSunBlast>(), projectile.damage, projectile.knockBack, projectile.owner, MathHelper.WrapAngle(offset.ToRotation()), 32); } } } else { if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType <MoonLordSunBlast>(), 0, 0f, projectile.owner); } } }
public override bool PreAI() { if (projectile.ai[0] == 0) { projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); projectile.ai[0] = 1; } else { projectile.rotation += (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y)) * 0.03f * (float)projectile.direction; if (projectile.ai[1] == 0 && Main.netMode != 1) { target = -1; float distance = 320; for (int k = 0; k < 200; k++) { if (Main.npc[k].active && Main.npc[k].CanBeChasedBy(projectile, false) && Collision.CanHitLine(projectile.Center, 1, 1, Main.npc[k].Center, 1, 1)) { Vector2 center = Main.npc[k].Center; float currentDistance = Vector2.Distance(center, projectile.Center); if (currentDistance < distance || target == -1) { distance = currentDistance; target = k; } } } if (target != -1) { projectile.ai[1] = 1; projectile.netUpdate = true; } } else { NPC targetNPC = Main.npc[this.target]; if (!targetNPC.active || !targetNPC.CanBeChasedBy(projectile, false) || !Collision.CanHitLine(projectile.Center, 1, 1, targetNPC.Center, 1, 1)) { this.target = -1; projectile.ai[1] = 0; projectile.netUpdate = true; } else { float currentRot = projectile.velocity.ToRotation(); Vector2 direction = targetNPC.Center - projectile.Center; float targetAngle = direction.ToRotation(); if (direction == Vector2.Zero) { targetAngle = currentRot; } float desiredRot = currentRot.AngleLerp(targetAngle, 0.04f); projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(desiredRot, default(Vector2)); } } } if (projectile.timeLeft <= 30) { projectile.Opacity -= 0.032F; } return(false); }
public override void AI() { //Lighting.AddLight(projectile.Center, 0.8052f, 0.1818f, 1f); int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 173, 0f, 0f); Main.dust[dust].scale = 1f; Main.dust[dust].noGravity = true; if (projectile.velocity.X > 0) { projectile.spriteDirection = 1; } else { projectile.spriteDirection = -1; } Vector2 target = projectile.position; float minimumRange = 800f; bool flag = false; if (!hasHitSomething && projectile.ai[0] != 1f && projectile.ai[1] > 10f) { for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.CanBeChasedBy((object)projectile, false)) { Vector2 distance = npc.Center - projectile.Center; float length = distance.Length(); if (length < minimumRange && Collision.CanHit(projectile.Center, 1, 1, npc.position, npc.width, npc.height) && Math.Abs(projectile.velocity.ToRotation() - distance.ToRotation()) < 2.35619449) //dont target enemies directly behind self { minimumRange = length; target = npc.Center; flag = true; } } } } if (!flag) { target = projectile.Center + projectile.velocity * 100; if (projectile.ai[1] >= 30) { projectile.ai[0] = 1f; projectile.ai[1] = 0f; projectile.netUpdate = true; } } float num8 = 0.25f; Vector2 vector2 = target - projectile.Center; float num12 = 12f / vector2.Length(); vector2 *= num12; if (projectile.velocity.X < vector2.X) { projectile.velocity.X += num8; if (projectile.velocity.X < 0 && vector2.X > 0) { projectile.velocity.X += num8 * 2f; } } else if (projectile.velocity.X > vector2.X) { projectile.velocity.X -= num8; if (projectile.velocity.X > 0 && vector2.X < 0) { projectile.velocity.X -= num8 * 2f; } } if (projectile.velocity.Y < vector2.Y) { projectile.velocity.Y += num8; if (projectile.velocity.Y < 0 && vector2.Y > 0) { projectile.velocity.Y += num8 * 2f; } } else if (projectile.velocity.Y > vector2.Y) { projectile.velocity.Y -= num8; if (projectile.velocity.Y > 0 && vector2.Y < 0) { projectile.velocity.Y -= num8 * 2f; } } //Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0f, 0f, mod.ProjectileType("BChakramContact"), projectile.damage, projectile.knockBack, projectile.owner); }
public override bool PreAI() { if (projectile.ai[0] == 1) { projectile.ai[1]++; projectile.rotation += projectile.direction * -0.4f; if (projectile.ai[1] <= 50) { projectile.velocity = Vector2.Lerp(projectile.velocity, Vector2.Zero, 0.1f); //fire lasers at cursor if (projectile.ai[1] % 10 == 0) { Vector2 cursor = Main.MouseWorld; Vector2 velocity = Vector2.Normalize(cursor - projectile.Center); if (projectile.ai[1] > 10) { velocity = velocity.RotatedByRandom(Math.PI / 24); } float num = 24f; for (int index1 = 0; index1 < num; ++index1) { int type = 235; Vector2 v = (Vector2.UnitX * 0.0f + -Vector2.UnitY.RotatedBy(index1 * (MathHelper.TwoPi / num), new Vector2()) * new Vector2(1f, 4f)).RotatedBy(velocity.ToRotation()); int index2 = Dust.NewDust(projectile.Center, 0, 0, type, 0.0f, 0.0f, 150, new Color(255, 153, 145), 1f); Main.dust[index2].scale = 1.5f; Main.dust[index2].fadeIn = 1.3f; Main.dust[index2].noGravity = true; Main.dust[index2].position = projectile.Center + (v * projectile.scale * 1.5f); Main.dust[index2].velocity = v.SafeNormalize(Vector2.UnitY); } Player player = Main.player[projectile.owner]; Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType <RetiDeathray>(), projectile.damage, 1f, projectile.owner, 0, projectile.whoAmI); projectile.velocity = -velocity * 8; if (empowered) { for (int i = -1; i <= 1; i += 2) { int p = Projectile.NewProjectile(projectile.Center, 1.25f * velocity.RotatedBy(MathHelper.ToRadians(90) * i), ModContent.ProjectileType <DarkStarHomingFriendly>(), projectile.damage, 1f, projectile.owner, -1, 0); if (p != Main.maxProjectiles) { Main.projectile[p].minion = false; Main.projectile[p].melee = true; Main.projectile[p].timeLeft = 75; } } } } } if (projectile.ai[1] > 60) { projectile.ai[1] = 15; projectile.ai[0] = 2; } return(false); } return(true); }
public override void OnHitNPC(Projectile projectile, NPC target, int damage, float knockback, bool crit) { Player player = Main.player[projectile.owner]; MyPlayer modPlayer = (MyPlayer)player.GetModPlayer(mod, "MyPlayer"); if (modPlayer.voidArmor) { foreach (int nPC in cantHit) { if (target.type != nPC && !target.SpawnedFromStatue) { if (Main.rand.Next(5) == 0) { float healAmount = Main.rand.Next(2, 8); int num1 = projectile.owner; Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, mod.ProjectileType("VoidHeal"), 0, 0f, projectile.owner, (float)num1, healAmount); // ai 1 is how much it heals } } } } if (modPlayer.heartContainer && projectile.minion) { foreach (int nPC in cantHit) { if (target.type != nPC && !target.SpawnedFromStatue) { if (Main.rand.Next(16) == 0) { float healAmount = Main.rand.Next(2, 8); int num1 = projectile.owner; Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, mod.ProjectileType("HeartContainerHeal"), 0, 0f, projectile.owner, (float)num1, healAmount); // ai 1 is how much it heals } } } } if (modPlayer.venomSample) { target.AddBuff(BuffID.Venom, 120); target.AddBuff(BuffID.Poisoned, 120); } if (modPlayer.frozenGauntlet) { target.AddBuff(BuffID.Frostburn, 200); } if (modPlayer.dragonmailGreathelm && projectile.melee) { target.AddBuff(mod.BuffType("Dragonfire"), 300, false); } if (modPlayer.dragonmailHood && projectile.magic) { target.AddBuff(mod.BuffType("Dragonfire"), 300, false); } if (modPlayer.dragonmailVisage && projectile.ranged) { target.AddBuff(mod.BuffType("Dragonfire"), 300, false); if (Main.rand.Next(15) == 0) { for (int k = 0; k < 3; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 174, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); Projectile.NewProjectile(projectile.position.X, projectile.position.Y, (float)Main.rand.Next(-35, 36) * 0.2f, (float)Main.rand.Next(-35, 36) * 0.2f, mod.ProjectileType("GreekFire"), projectile.damage / 2, projectile.knockBack * 0.35f, Main.myPlayer, 0f, 0f); } Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); } } if (modPlayer.dragonmailMask && projectile.minion) { target.AddBuff(mod.BuffType("Dragonfire"), 300, false); } if (modPlayer.voidWalkerArmor == 1 && projectile.melee) { target.AddBuff(mod.BuffType("ExtinctionCurse"), 300, false); } if (modPlayer.voidWalkerArmor == 2 && projectile.ranged) { target.AddBuff(mod.BuffType("ExtinctionCurse"), 300, false); } if (modPlayer.voidWalkerArmor == 3 && projectile.magic) { target.AddBuff(mod.BuffType("ExtinctionCurse"), 300, false); } if (modPlayer.voidWalkerArmor == 4 && projectile.minion) { target.AddBuff(mod.BuffType("ExtinctionCurse"), 300, false); } if (modPlayer.neovirtuoBonus && Main.rand.Next(9) == 0 && projectile.type != mod.ProjectileType("NeovirtuoHoming")) { if (modPlayer.neovirtuoTimer <= 0) { Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 84); int neoDamage = 200; int speed = 8; Projectile.NewProjectile(player.Center.X, player.Center.Y, speed, speed, mod.ProjectileType("NeovirtuoHoming"), neoDamage, 1.25f, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(player.Center.X, player.Center.Y, speed, -speed, mod.ProjectileType("NeovirtuoHoming"), neoDamage, 1.25f, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(player.Center.X, player.Center.Y, -speed, speed, mod.ProjectileType("NeovirtuoHoming"), neoDamage, 1.25f, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(player.Center.X, player.Center.Y, -speed, -speed, mod.ProjectileType("NeovirtuoHoming"), neoDamage, 1.25f, Main.myPlayer, 0f, 0f); modPlayer.neovirtuoTimer = 15; } } if (modPlayer.immortalResolve) { if (crit && modPlayer.immortalResolveCooldown <= 0) { int randLife = 0; if (player.magicCrit < 10 && player.meleeCrit < 10 && player.rangedCrit < 10 && player.thrownCrit < 10) { randLife = Main.rand.Next(1, 18); } if (player.magicCrit >= 10 && player.meleeCrit >= 10 && player.rangedCrit >= 10 && player.thrownCrit >= 10 && player.magicCrit < 25 && player.meleeCrit < 25 && player.rangedCrit < 25 && player.thrownCrit < 25) { randLife = Main.rand.Next(1, 12); } if (player.magicCrit >= 25 && player.meleeCrit >= 25 && player.rangedCrit >= 25 && player.thrownCrit >= 25 && player.magicCrit < 75 && player.meleeCrit < 75 && player.rangedCrit < 75 && player.thrownCrit < 75) { randLife = Main.rand.Next(1, 8); } if (player.magicCrit >= 75 && player.meleeCrit >= 75 && player.rangedCrit >= 75 && player.thrownCrit >= 75) { randLife = Main.rand.Next(1, 5); } player.statLife += randLife; player.HealEffect(randLife); modPlayer.immortalResolveCooldown = 10; } } if (modPlayer.crowsArmor && modPlayer.crowsArmorCooldown <= 0) { float lightningSpeed = 8f; Vector2 spawnpoint = new Vector2(target.Center.X, target.Center.Y - 100); float rotation = -(float)Math.Atan2(spawnpoint.X - target.Center.Y, spawnpoint.X - target.Center.X); Vector2 speed = new Vector2((float)((Math.Cos(rotation) * lightningSpeed) * -1), (float)((Math.Sin(rotation) * lightningSpeed) * -1)); Vector2 vector94 = new Vector2(speed.X, speed.Y); float ai = (float)Main.rand.Next(100); Vector2 vector95 = Vector2.Normalize(vector94) * 2f; Projectile.NewProjectile(spawnpoint.X, spawnpoint.Y, vector95.X, vector95.Y, mod.ProjectileType("CrowLightning"), 100, 0f, Main.myPlayer, vector94.ToRotation(), ai); Projectile.NewProjectile(spawnpoint.X, spawnpoint.Y, 0f, 0f, mod.ProjectileType("CrowStorm"), 0, 0f, Main.myPlayer); modPlayer.crowsArmorCooldown = 30; } if (modPlayer.cosmicGlass && crit && modPlayer.cosmicGlassCD <= 0 && projectile.type != mod.ProjectileType("ChargeRifleHalf")) { if (target.active && !target.friendly && target.damage > 0 && !target.dontTakeDamage) { float Speed = 9f; float rotation = (float)Math.Atan2(player.Center.Y - target.Center.Y, player.Center.X - target.Center.X); Vector2 speed = new Vector2((float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1)); Main.PlaySound(2, (int)player.position.X, (int)player.position.Y, 12); Projectile.NewProjectile(player.Center.X, player.Center.Y, speed.X, speed.Y, mod.ProjectileType("ChargeRifleHalf"), 30, 3f, projectile.owner, 0f); modPlayer.cosmicGlassCD = 3; } } if (modPlayer.sufferWithMe && Main.rand.Next(4) == 0) { target.AddBuff(mod.BuffType("ChaosBurn"), 300, false); } int strikeChance = 10; if (NPC.downedBoss3) { strikeChance = 7; } if (Main.hardMode) { strikeChance = 5; } if (NPC.downedPlantBoss) { strikeChance = 4; } if (NPC.downedMoonlord) { strikeChance = 2; } if (modPlayer.strangeUkulele && Main.rand.Next(strikeChance) == 0) { List <int> availableNPCs = new List <int>(); for (int k = 0; k < Main.npc.Length; k++) { NPC other = Main.npc[k]; if (other.active && !other.friendly && other.damage > 0 && !other.dontTakeDamage && Vector2.Distance(other.Center, player.Center) < 300) { availableNPCs.Add(other.whoAmI); } } if (availableNPCs.Count > 0) { NPC arcTarget = Main.npc[availableNPCs[Main.rand.Next(availableNPCs.Count)]]; if (arcTarget.active && !arcTarget.friendly && arcTarget.damage > 0 && !arcTarget.dontTakeDamage) { Main.PlaySound(2, -1, -1, mod.GetSoundSlot(SoundType.Item, "Sounds/Item/ElectricArcing")); float Speed = 9f; float rotation = (float)Math.Atan2(player.Center.Y - target.Center.Y, player.Center.X - target.Center.X); rotation += MathHelper.ToRadians(Main.rand.Next(-60, 60)); Vector2 speed = new Vector2((float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1)); Projectile.NewProjectile(player.Center.X, player.Center.Y, speed.X, speed.Y, mod.ProjectileType("UkuleleArc"), 30, 3f, player.whoAmI, arcTarget.whoAmI); } } } }
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Npc[NPC.type].Value; //int num156 = Terraria.GameContent.TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; //ypos of lower right corner of sprite to draw //int y3 = num156 * NPC.frame.Y; //ypos of upper left corner of sprite to draw Rectangle rectangle = NPC.frame;//new Rectangle(0, y3, texture2D13.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; Color color26 = drawColor; color26 = NPC.GetAlpha(color26); SpriteEffects effects = NPC.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; float scale = (Main.mouseTextColor / 200f - 0.35f) * 0.4f + 0.8f; Main.EntitySpriteDraw(texture2D13, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), NPC.GetAlpha(drawColor) * 0.5f, NPC.rotation, origin2, NPC.scale * scale, effects, 0); Main.EntitySpriteDraw(texture2D13, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), NPC.GetAlpha(drawColor), NPC.rotation, origin2, NPC.scale, effects, 0); for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <NatureChampionHead>() && Main.npc[i].ai[1] == NPC.whoAmI) { if (NPC.Distance(Main.LocalPlayer.Center) <= 1200) { string neckTex = "NPCs/Champions/NatureChampion_Neck"; Texture2D neckTex2D = FargowiltasSouls.Instance.Assets.Request <Texture2D>(neckTex, ReLogic.Content.AssetRequestMode.ImmediateLoad).Value; Vector2 connector = Main.npc[i].Center; Vector2 neckOrigin = NPC.Center + new Vector2(54 * NPC.spriteDirection, -10); float chainsPerUse = 0.05f; for (float j = 0; j <= 1; j += chainsPerUse) { if (j == 0) { continue; } Vector2 distBetween = new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X) - X(j - chainsPerUse, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X), Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y) - Y(j - chainsPerUse, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y)); if (distBetween.Length() > 36 && chainsPerUse > 0.01f) { chainsPerUse -= 0.01f; j -= chainsPerUse; continue; } float projTrueRotation = distBetween.ToRotation() - (float)Math.PI / 2; Vector2 lightPos = new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X), Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y)); spriteBatch.Draw(neckTex2D, new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X) - screenPos.X, Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y) - screenPos.Y), new Rectangle(0, 0, neckTex2D.Width, neckTex2D.Height), NPC.GetAlpha(Lighting.GetColor((int)lightPos.X / 16, (int)lightPos.Y / 16)), projTrueRotation, new Vector2(neckTex2D.Width * 0.5f, neckTex2D.Height * 0.5f), 1f, connector.X < neckOrigin.X ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); } } /*Texture2D texture = FargowiltasSouls.Instance.Assets.Request<Texture2D>("NPCs/Champions/NatureChampion_Neck", ReLogic.Content.AssetRequestMode.ImmediateLoad).Value; * Vector2 position = Main.npc[i].Center; * Vector2 mountedCenter = NPC.Center + new Vector2(54 * NPC.spriteDirection, -10); * Rectangle? sourceRectangle = new Rectangle?(); * Vector2 origin = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f); * float num1 = texture.Height; * Vector2 vector24 = mountedCenter - position; * float rotation = (float)Math.Atan2(vector24.Y, vector24.X) - 1.57f; * bool flag = true; * if (float.IsNaN(position.X) && float.IsNaN(position.Y)) * flag = false; * if (float.IsNaN(vector24.X) && float.IsNaN(vector24.Y)) * flag = false; * while (flag) * if (vector24.Length() < num1 + 1.0) * { * flag = false; * } * else * { * Vector2 vector21 = vector24; * vector21.Normalize(); * position += vector21 * num1; * vector24 = mountedCenter - position; * Color color2 = Lighting.GetColor((int)position.X / 16, (int)(position.Y / 16.0)); * color2 = NPC.GetAlpha(color2); * Main.EntitySpriteDraw(texture, position - screenPos, sourceRectangle, color2, rotation, origin, 1f, * position.X < mountedCenter.X ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); * }*/ DrawHead(spriteBatch, screenPos, Lighting.GetColor((int)Main.npc[i].Center.X / 16, (int)Main.npc[i].Center.Y / 16), Main.npc[i]); } } return(false); }
public override void AI() { Player player = Main.player[projectile.owner]; Vector2 direction = player.Center - projectile.Center; if (direction.X > 0f) { projectile.spriteDirection = 1; projectile.rotation = direction.ToRotation(); } if (direction.X < 0f) { projectile.spriteDirection = -1; projectile.rotation = direction.ToRotation() + 1.57f; } projectile.rotation += MathHelper.ToRadians(45); if (projectile.localAI[0] == 0) { Main.PlaySound(2, -1, -1, mod.GetSoundSlot(SoundType.Item, "Sounds/Item/LaserCharge")); projectile.localAI[0]++; } aiTimer++; shootTimer--; Vector2 offset = new Vector2(100, 0); Projectile parent = Main.projectile[(int)projectile.ai[1]]; if (increase <= 0.25f) // 0.3 { increase += 0.001f; if (aiTimer > 30) { increase += 0.001f; } if (aiTimer > 45) { increase += 0.001f; } if (aiTimer > 50) { increase += 0.001f; } } projectile.ai[0] += increase; projectile.position = parent.Center + offset.RotatedBy(projectile.ai[0] * (Math.PI * 2 / 8)) - new Vector2(projectile.width / 2, projectile.height / 2); // if the projectile isnt dust, you gotta subtract half the size to make it change the projectile center if (parent.active == false) { projectile.Kill(); } if (increase >= 0.24f && shootTimer <= 0) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 33); float Speed = 15f; Vector2 vector8 = new Vector2(projectile.position.X + (projectile.width / 2), projectile.position.Y + (projectile.height / 2)); int damage = 400; int type = mod.ProjectileType("DeathwarpLaser"); Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 21); float rotation = (float)Math.Atan2(vector8.Y - (player.position.Y + (player.height * 0.5f)), vector8.X - (player.position.X + (player.width * 0.5f))); int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, -((float)((Math.Cos(rotation) * Speed) * -1)), -((float)((Math.Sin(rotation) * Speed) * -1)), type, damage, 0f, 0); // reverse speed to shoot away from player shootTimer = 3; } }
private void ThrowingKnives(StandState sender) { if (Animations[CurrentAnimation].CurrentFrame == 10) { int knifeCount = 4; float spread = 4 * knifeCount; for (int i = 0; i < knifeCount; i++) { Vector2 direction = projectile.Center.DirectTo(MousePosition, 14f); float offY = spread - ((spread * 0.5f) * i); Vector2 position = projectile.Center + direction * 2.2f + new Vector2(Main.rand.Next(-5, 5), -offY).RotatedBy(direction.ToRotation()); Projectile.NewProjectile(position, direction, ModContent.ProjectileType <Knife>(), KnifeDamage, 3.5f, Owner.whoAmI); } sender.OnStateUpdate -= ThrowingKnives; } }
public override void AI() { trigCounter += (float)Math.PI / 60; Player player = Main.player[projectile.owner]; player.UpdateMaxTurrets(); Vector2 DifferenceToGo = Goto - projectile.Center - HeadPos; float speed = DifferenceToGo.Length(); wanderTimer++; if (wanderTimer > 60) { if (Main.netMode == 1 && projectile.owner == Main.myPlayer) { projectile.ai[1] = Main.rand.NextFloat(2 * (float)Math.PI); if (Main.netMode == 1) { QwertysRandomContent.ProjectileAIUpdate(projectile); } projectile.netUpdate = true; } else if (Main.netMode == 0) { projectile.ai[1] = Main.rand.NextFloat(2 * (float)Math.PI); } wanderTimer = 0; } if (QwertyMethods.ClosestNPC(ref target, 700, projectile.Center, true, player.MinionAttackTargetNPC)) { Goto = target.Center; maxSpeed = 6; } else { Goto = projectile.Center + QwertyMethods.PolarVector(100, projectile.ai[1]); } if (speed > maxSpeed) { speed = maxSpeed; } HeadPos += QwertyMethods.PolarVector(speed, DifferenceToGo.ToRotation()); projectile.frameCounter++; if (projectile.frameCounter % 10 == 0) { if (frame == 2 || frame == 0) { animationDir *= -1; } frame += animationDir; } HeadOffPos = HeadPos + QwertyMethods.PolarVector(20 * (float)Math.Sin(trigCounter), HeadPos.ToRotation()); maxSpeed = 3; //were used to check hitbox //Dust.NewDustPerfect((projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(-13, HeadPos.ToRotation()), DustID.Fire); // Dust.NewDustPerfect((projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(28, HeadPos.ToRotation()), DustID.Fire); }
public override bool PreAI() { bool expertMode = Main.expertMode; if (start) { for (int num621 = 0; num621 < 15; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 1, 0f, 0f, 100, default(Color), 2f); } start = false; } npc.TargetClosest(true); Vector2 direction = Main.player[npc.target].Center - npc.Center; direction.Normalize(); direction *= 9f; npc.rotation = direction.ToRotation(); timer++; if (timer > 60) { if (Main.rand.Next(4) == 0) { for (int num621 = 0; num621 < 5; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 226, 0f, 0f, 100, default(Color), 2f); } int damage = expertMode ? 39 : 55; int proj2 = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction.X, direction.Y, ModContent.ProjectileType <MiracleBeam>(), damage, 1f, npc.target); } timer = 0; } for (int index1 = 0; index1 < 6; ++index1) { float x = (npc.Center.X - 22); float xnum2 = (npc.Center.X + 22); float y = (npc.Center.Y); if (npc.direction == -1) { int index2 = Dust.NewDust(new Vector2(x, y), 1, 1, 226, 0.0f, 0.0f, 0, new Color(), 1f); Main.dust[index2].position.X = x; Main.dust[index2].position.Y = y; Main.dust[index2].scale = .85f; Main.dust[index2].velocity *= 0.02f; Main.dust[index2].noGravity = true; Main.dust[index2].noLight = false; } else if (npc.direction == 1) { int index2 = Dust.NewDust(new Vector2(xnum2, y), 1, 1, 226, 0.0f, 0.0f, 0, new Color(), 1f); Main.dust[index2].position.X = xnum2; Main.dust[index2].position.Y = y; Main.dust[index2].scale = .85f; Main.dust[index2].velocity *= 0.02f; Main.dust[index2].noGravity = true; Main.dust[index2].noLight = false; } } int parent = (int)npc.ai[0]; if (parent < 0 || parent >= Main.maxNPCs || !Main.npc[parent].active || Main.npc[parent].type != ModContent.NPCType <Atlas>()) { npc.active = false; return(false); } npc.Center = Main.npc[parent].Center + npc.ai[2] * npc.ai[1].ToRotationVector2(); npc.ai[1] += .03f; return(false); }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { for (int k = 0; k <= 10; k++) { Vector2 vel = Vector2.Normalize(Main.MouseWorld - player.Center); Projectile.NewProjectile(player.Center.X, player.Center.Y, vel.X, vel.Y, ModContent.ProjectileType <WhipSegment1>(), damage, 0, player.whoAmI, k, vel.ToRotation()); } return(false); }
public override void AI() { projectile.scale *= 1.002f; projectile.rotation += 100; int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 63, projectile.velocity.X, projectile.velocity.Y, 0, Color.White, 1); Main.dust[dust].velocity /= 1.2f; Main.dust[dust].noGravity = true; projectile.localAI[1]++; if (projectile.localAI[1] > 10f && Main.rand.Next(3) == 0) { projectile.alpha -= 5; if (projectile.alpha < 50) { projectile.alpha = 50; } Lighting.AddLight((int)projectile.Center.X / 16, (int)projectile.Center.Y / 16, 0.1f, 0.4f, 0.6f); } int num718 = -1; Vector2 vector52 = projectile.Center; float num719 = 500f; if (projectile.localAI[0] > 0f) { projectile.localAI[0]--; } if (projectile.ai[0] == 0f && projectile.localAI[0] == 0f) { for (int num720 = 0; num720 < 200; num720++) { NPC nPC6 = Main.npc[num720]; if (nPC6.CanBeChasedBy(this) && (projectile.ai[0] == 0f || projectile.ai[0] == (float)(num720 + 1))) { Vector2 center4 = nPC6.Center; float num721 = Vector2.Distance(center4, vector52); if (num721 < num719 && Collision.CanHit(projectile.position, projectile.width, projectile.height, nPC6.position, nPC6.width, nPC6.height)) { num719 = num721; vector52 = center4; num718 = num720; } } } if (num718 >= 0) { projectile.ai[0] = num718 + 1; projectile.netUpdate = true; } num718 = -1; } if (projectile.localAI[0] == 0f && projectile.ai[0] == 0f) { projectile.localAI[0] = 30f; } bool flag32 = false; if (projectile.ai[0] != 0f) { int num722 = (int)(projectile.ai[0] - 1f); if (Main.npc[num722].active && !Main.npc[num722].dontTakeDamage && Main.npc[num722].immune[projectile.owner] == 0) { float num723 = Main.npc[num722].position.X + (float)(Main.npc[num722].width / 2); float num724 = Main.npc[num722].position.Y + (float)(Main.npc[num722].height / 2); float num725 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num723) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num724); if (num725 < 1000f) { flag32 = true; vector52 = Main.npc[num722].Center; } } else { projectile.ai[0] = 0f; flag32 = false; projectile.netUpdate = true; } } if (flag32) { Vector2 v = vector52 - projectile.Center; float num726 = projectile.velocity.ToRotation(); float num727 = v.ToRotation(); double num728 = num727 - num726; if (num728 > Math.PI) { num728 -= Math.PI * 2.0; } if (num728 < -Math.PI) { num728 += Math.PI * 2.0; } projectile.velocity = projectile.velocity.RotatedBy(num728 * 0.10000000149011612); } float num729 = projectile.velocity.Length(); projectile.velocity.Normalize(); projectile.velocity *= num729 + 0.0025f; }
public override void AI() { projectile.velocity *= 1.0005f; if (projectile.alpha >= 120) { projectile.alpha -= 10; } int num4324; int num; for (int num20 = 0; num20 < 2; num20 = num4324 + 1) { float num21 = projectile.velocity.X / 4f * (float)num20; float num22 = projectile.velocity.Y / 4f * (float)num20; int num23 = Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("HollowBurn"), 0f, 0f, 0, default(Color), 0.6f); Main.dust[num23].position.X = projectile.Center.X - num21; Main.dust[num23].position.Y = projectile.Center.Y - num22; Dust dust3 = Main.dust[num23]; dust3.velocity *= 0f; Main.dust[num23].scale = 0.68f; Main.dust[num23].velocity *= 0.48f; Main.dust[num23].noGravity = true; Main.dust[num23].fadeIn = 1f; num4324 = num20; } if (projectile.ai[1] == 0f) { projectile.ai[1] = 1f; Main.PlaySound(SoundID.Item91, projectile.position); } else if (projectile.ai[1] == 1f && Main.netMode != 1) { int num3 = -1; float num4 = 2000f; for (int k = 0; k < 255; k = num + 1) { if (Main.player[k].active && !Main.player[k].dead) { Vector2 center = Main.player[k].Center; float num5 = Vector2.Distance(center, projectile.Center); if ((num5 < num4 || num3 == -1) && Collision.CanHit(projectile.Center, 1, 1, center, 1, 1)) { num4 = num5; num3 = k; } } num = k; } if (num4 < 20f) { projectile.Kill(); return; } if (num3 != -1) { projectile.ai[1] = 21f; projectile.ai[0] = (float)num3; projectile.netUpdate = true; } } else if (projectile.ai[1] > 20f && projectile.ai[1] < 200f) { projectile.ai[1] += 1f; int num6 = (int)projectile.ai[0]; if (!Main.player[num6].active || Main.player[num6].dead) { projectile.ai[1] = 1f; projectile.ai[0] = 0f; projectile.netUpdate = true; } else { float num7 = projectile.velocity.ToRotation(); Vector2 vector2 = Main.player[num6].Center - projectile.Center; if (vector2.Length() < 20f) { projectile.Kill(); return; } float targetAngle = vector2.ToRotation(); if (vector2 == Vector2.Zero) { targetAngle = num7; } float num8 = num7.AngleLerp(targetAngle, 0.008f); projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy((double)num8, default(Vector2)); } } if (projectile.ai[1] >= 1f && projectile.ai[1] < 20f) { projectile.ai[1] += 1f; if (projectile.ai[1] == 20f) { projectile.ai[1] = 1f; } } projectile.alpha -= 40; if (projectile.alpha < 0) { projectile.alpha = 0; } projectile.spriteDirection = projectile.direction; Lighting.AddLight(projectile.Center, 1.1f, 0.9f, 0.4f); projectile.localAI[0] += 1f; if (projectile.localAI[0] == 6f) { projectile.localAI[0] = 0f; for (int l = 0; l < 12; l = num + 1) { Vector2 vector3 = Vector2.UnitX * -(float)projectile.width / 2f; vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default(Vector2)) * new Vector2(2f, 4f); vector3 = vector3.RotatedBy((double)(projectile.rotation - 1.57079637f), default(Vector2)); int num9 = Dust.NewDust(projectile.Center, 0, 0, mod.DustType("HollowBurn"), 0f, 0f, 160, default(Color), 1f); Main.dust[num9].scale = 1.2f; Main.dust[num9].velocity *= 1.5f; Main.dust[num9].noGravity = true; Main.dust[num9].position = projectile.Center + vector3; Main.dust[num9].velocity = projectile.velocity * 0.1f; Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; num = l; } } for (int m = 0; m < 1; m = num + 1) { Vector2 value = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy((double)projectile.velocity.ToRotation(), default(Vector2)); int num10 = Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("HollowBurn"), 0f, 0f, 100, default(Color), 0.6f); Dust dust3 = Main.dust[num10]; dust3.velocity *= 0.1f; Main.dust[num10].velocity *= 0.2f; Main.dust[num10].noGravity = true; Main.dust[num10].position = projectile.Center + value * (float)projectile.width / 2f; Main.dust[num10].fadeIn = 1f; num = m; } for (int n = 0; n < 1; n = num + 1) { Vector2 value2 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy((double)projectile.velocity.ToRotation(), default(Vector2)); int num11 = Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("HollowBurn"), 0f, 0f, 155, default(Color), 0.48f); Dust dust3 = Main.dust[num11]; dust3.velocity *= 0f; dust3.fadeIn = 0.7f; Main.dust[num11].noGravity = true; Main.dust[num11].position = projectile.Center + value2 * (float)projectile.width / 2f; if (Main.rand.Next(2) == 0) { Main.dust[num11].fadeIn = 0.9f; } num = n; } }
protected override void UpdateVisualRotation(Vector2 direction) { thisTransform.rotation = direction.ToRotation(); }
public override void AI() { if (projectile.ai[1] > -1f && projectile.ai[1] < 200f) { NPC npc = Main.npc[(int)projectile.ai[1]]; if (npc.CanBeChasedBy(projectile)) { float rotation = projectile.velocity.ToRotation(); Vector2 vel = npc.Center - projectile.Center; if (vel.Length() < 20f) { projectile.Kill(); return; } float targetAngle = vel.ToRotation(); projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(rotation.AngleLerp(targetAngle, 0.008f)); } else { projectile.ai[1] = -1f; projectile.netUpdate = true; } } projectile.alpha -= 40; if (projectile.alpha < 0) { projectile.alpha = 0; } projectile.frameCounter++; if (projectile.frameCounter > 2) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame > 3) { projectile.frame = 0; } } Lighting.AddLight(projectile.Center, 1.1f, 0.9f, 0.4f); projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2; ++projectile.localAI[0]; if ((double)projectile.localAI[0] == 12.0) //loads of vanilla dust :echprime: { projectile.localAI[0] = 0.0f; for (int index1 = 0; index1 < 12; ++index1) { Vector2 vector2 = (Vector2.UnitX * (float)-projectile.width / 2f + -Vector2.UnitY.RotatedBy((double)index1 * 3.14159274101257 / 6.0, new Vector2()) * new Vector2(8f, 16f)).RotatedBy((double)projectile.rotation - 1.57079637050629, new Vector2()); int index2 = Dust.NewDust(projectile.Center, 0, 0, 6, 0.0f, 0.0f, 160, new Color(), 1f); Main.dust[index2].scale = 1.1f; Main.dust[index2].noGravity = true; Main.dust[index2].position = projectile.Center + vector2; Main.dust[index2].velocity = projectile.velocity * 0.1f; Main.dust[index2].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[index2].position) * 1.25f; } } if (Main.rand.Next(4) == 0) { for (int index1 = 0; index1 < 1; ++index1) { Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.196349546313286).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1f); Main.dust[index2].velocity *= 0.1f; Main.dust[index2].position = projectile.Center + vector2 * (float)projectile.width / 2f; Main.dust[index2].fadeIn = 0.9f; } } if (Main.rand.Next(32) == 0) { for (int index1 = 0; index1 < 1; ++index1) { Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.392699092626572).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0.0f, 0.0f, 155, new Color(), 0.8f); Main.dust[index2].velocity *= 0.3f; Main.dust[index2].position = projectile.Center + vector2 * (float)projectile.width / 2f; if (Main.rand.Next(2) == 0) { Main.dust[index2].fadeIn = 1.4f; } } } if (Main.rand.Next(2) == 0) { for (int index1 = 0; index1 < 2; ++index1) { Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.785398185253143).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0.0f, 0.0f, 0, new Color(), 1.2f); Main.dust[index2].velocity *= 0.3f; Main.dust[index2].noGravity = true; Main.dust[index2].position = projectile.Center + vector2 * (float)projectile.width / 2f; if (Main.rand.Next(2) == 0) { Main.dust[index2].fadeIn = 1.4f; } } } }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; Color color = lightColor; // Some rectangle presets for different parts of the chain. Rectangle chainHandle = new Rectangle(0, 2, texture.Width, 40); Rectangle chainLinkEnd = new Rectangle(0, 68, texture.Width, 18); Rectangle chainLink = new Rectangle(0, 46, texture.Width, 18); Rectangle chainHead = new Rectangle(0, 90, texture.Width, 48); // If the chain isn't moving, stop drawing all of its components. if (projectile.velocity == Vector2.Zero) { return(false); } // These fields / pre-draw logic have been taken from the vanilla source code for the Solar Eruption. // They setup distances, directions, offsets, and rotations all so the chain faces correctly. float chainDistance = projectile.velocity.Length() + 16f; bool distanceCheck = chainDistance < 100f; Vector2 direction = Vector2.Normalize(projectile.velocity); Rectangle rectangle = chainHandle; Vector2 yOffset = new Vector2(0f, Main.player[projectile.owner].gfxOffY); float rotation = direction.ToRotation() + MathHelper.ToRadians(-90f); // Draw the chain handle. This is the first piece in the sprite. spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + yOffset, rectangle, color, rotation, rectangle.Size() / 2f - Vector2.UnitY * 4f, projectile.scale, SpriteEffects.None, 0f); chainDistance -= 40f * projectile.scale; Vector2 position = projectile.Center; position += direction * projectile.scale * 24f; rectangle = chainLinkEnd; if (chainDistance > 0f) { float chains = 0f; while (chains + 1f < chainDistance) { if (chainDistance - chains < rectangle.Height) { rectangle.Height = (int)(chainDistance - chains); } // Draws the chain links between the handle and the head. This is the "line," or the third piece in the sprite. spriteBatch.Draw(texture, position - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)position.X / 16, (int)position.Y / 16), rotation, new Vector2(rectangle.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f); chains += rectangle.Height * projectile.scale; position += direction * rectangle.Height * projectile.scale; } } Vector2 chainEnd = position; position = projectile.Center; position += direction * projectile.scale * 24f; rectangle = chainLink; int offset = distanceCheck ? 9 : 18; float chainLinkDistance = chainDistance; if (chainDistance > 0f) { float chains = 0f; float increment = chainLinkDistance / offset; chains += increment * 0.25f; position += direction * increment * 0.25f; for (int i = 0; i < offset; i++) { float spacing = increment; if (i == 0) { spacing *= 0.75f; } // Draws the actual chain link spikes between the handle and the head. These are the "spikes," or the second piece in the sprite. spriteBatch.Draw(texture, position - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)position.X / 16, (int)position.Y / 16), rotation, new Vector2(rectangle.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f); chains += spacing; position += direction * spacing; } } rectangle = chainHead; // Draw the chain head. This is the fourth piece in the sprite. spriteBatch.Draw(texture, chainEnd - Main.screenPosition + yOffset, rectangle, Lighting.GetColor((int)chainEnd.X / 16, (int)chainEnd.Y / 16), rotation, texture.Frame().Top(), projectile.scale, SpriteEffects.None, 0f); // Because the chain head's draw position isn't determined in AI, it is set in PreDraw. // This is so the smoke-spawning dust and white light are at the proper location. chainHeadPosition = chainEnd; return(false); }
public override void HitEffect(int hitDirection, double damage) { if (NPC.life <= 0) { for (int i = 1; i <= 6; i++) { Vector2 pos = NPC.position + new Vector2(Main.rand.NextFloat(NPC.width), Main.rand.NextFloat(NPC.height)); if (!Main.dedServ) { Gore.NewGore(NPC.GetSource_FromThis(), pos, NPC.velocity, ModContent.Find <ModGore>(Mod.Name, $"NatureGore{i}").Type, NPC.scale); } } for (int i = 0; i < Main.maxNPCs; i++) //find neck segments, place gores there { if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <NatureChampionHead>() && Main.npc[i].ai[1] == NPC.whoAmI) { Vector2 connector = Main.npc[i].Center; Vector2 neckOrigin = NPC.Center + new Vector2(54 * NPC.spriteDirection, -10); float chainsPerUse = 0.05f; bool spawnNeck = false; for (float j = 0; j <= 1; j += chainsPerUse) { if (j == 0) { continue; } Vector2 distBetween = new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X) - X(j - chainsPerUse, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X), Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y) - Y(j - chainsPerUse, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y)); if (distBetween.Length() > 36 && chainsPerUse > 0.01f) { chainsPerUse -= 0.01f; j -= chainsPerUse; continue; } float projTrueRotation = distBetween.ToRotation() - (float)Math.PI / 2; Vector2 lightPos = new Vector2(X(j, neckOrigin.X, (neckOrigin.X + connector.X) / 2, connector.X), Y(j, neckOrigin.Y, (neckOrigin.Y + 50), connector.Y)); spawnNeck = !spawnNeck; if (spawnNeck) { if (!Main.dedServ) { Gore.NewGore(NPC.GetSource_FromThis(), lightPos, Main.npc[i].velocity, ModContent.Find <ModGore>(Mod.Name, "NatureGore7").Type, Main.npc[i].scale); } } } for (int j = 8; j <= 10; j++) //head gores { Vector2 pos = Main.npc[i].position + new Vector2(Main.rand.NextFloat(Main.npc[i].width), Main.rand.NextFloat(Main.npc[i].height)); if (!Main.dedServ) { Gore.NewGore(NPC.GetSource_FromThis(), pos, Main.npc[i].velocity, ModContent.Find <ModGore>(Mod.Name, $"NatureGore{j}").Type, Main.npc[i].scale); } } } } } }
public override void AI() { if ((double)Vector2.Distance(Main.player[projectile.owner].Center, projectile.Center) > 1000.0) { projectile.Kill(); } if (projectile.velocity == Vector2.Zero) { float num1 = (float)((double)projectile.rotation + 1.57079637050629 + (Main.rand.Next(2) == 1 ? -1.0 : 1.0) * 1.57079637050629); float num2 = (float)(Main.rand.NextDouble() * 1.25 + 1.25); Vector2 vector2 = new Vector2((float)Math.Cos((double)num1) * num2, (float)Math.Sin((double)num1) * num2); } if (projectile.timeLeft >= 596) { return; } if ((double)projectile.localAI[1] == 0.0 && (double)projectile.ai[0] >= 900.0) { projectile.ai[0] -= 1000f; projectile.localAI[1] = -1f; } projectile.frameCounter = projectile.frameCounter + 1; Lighting.AddLight(projectile.Center, 0.3f, 0.45f, 0.5f); if (projectile.velocity == Vector2.Zero) { if (projectile.frameCounter >= projectile.extraUpdates * 2) { projectile.frameCounter = 0; bool flag = true; for (int index = 1; index < projectile.oldPos.Length; ++index) { if (projectile.oldPos[index] != projectile.oldPos[0]) { flag = false; } } if (flag) { projectile.Kill(); } } if (Main.rand.Next(projectile.extraUpdates) != 0 || !(projectile.velocity != Vector2.Zero) && Main.rand.Next((double)projectile.localAI[1] == 2.0 ? 2 : 6) != 0) { return; } for (int k = 0; k < 2; k++) { float num1 = projectile.rotation + (float)((Main.rand.Next(2) == 1 ? -1.0 : 1.0) * 1.57079637050629); float num2 = (float)(Main.rand.NextDouble() * 0.800000011920929 + 1.0); Vector2 vector2 = new Vector2((float)Math.Cos((double)num1) * num2, (float)Math.Sin((double)num1) * num2); } if (Main.rand.Next(5) != 0) { return; } int index3 = Dust.NewDust(projectile.Center + projectile.velocity.RotatedBy(1.57079637050629, new Vector2()) * ((float)Main.rand.NextDouble() - 0.5f) * (float)projectile.width - Vector2.One * 4f, 8, 8, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); Main.dust[index3].velocity *= 0.5f; Main.dust[index3].velocity.Y = -Math.Abs(Main.dust[index3].velocity.Y); } else { if (projectile.frameCounter < projectile.extraUpdates * 2) { return; } projectile.frameCounter = 0; float num1 = projectile.velocity.Length(); UnifiedRandom unifiedRandom = new UnifiedRandom((int)projectile.ai[1]); int num2 = 0; Vector2 spinningpoint = -Vector2.UnitY; Vector2 rotationVector2; int num3; do { int num4 = unifiedRandom.Next(); projectile.ai[1] = (float)num4; rotationVector2 = ((float)((double)(num4 % 100) / 100.0 * 6.28318548202515)).ToRotationVector2(); if ((double)rotationVector2.Y > 0.0) { rotationVector2.Y *= -1f; } bool flag = false; if ((double)rotationVector2.Y > -0.0199999995529652) { flag = true; } if ((double)rotationVector2.X * (double)(projectile.extraUpdates + 1) * 2.0 * (double)num1 + (double)projectile.localAI[0] > 25.0) { flag = true; } if ((double)rotationVector2.X * (double)(projectile.extraUpdates + 1) * 2.0 * (double)num1 + (double)projectile.localAI[0] < -25.0) { flag = true; } if (flag) { num3 = num2; num2 = num3 + 1; } else { goto label_36; } }while (num3 < 100); projectile.velocity = Vector2.Zero; if ((double)projectile.localAI[1] < 1.0) { projectile.localAI[1] += 2f; goto label_37; } else { goto label_37; } label_36: spinningpoint = rotationVector2; label_37: if (!(projectile.velocity != Vector2.Zero)) { return; } projectile.localAI[0] += (float)((double)spinningpoint.X * (double)(projectile.extraUpdates + 1) * 2.0) * num1; projectile.velocity = spinningpoint.RotatedBy((double)projectile.ai[0] + 1.57079637050629, new Vector2()) * num1; projectile.rotation = projectile.velocity.ToRotation() + 1.570796f; if (Main.rand.Next(5) != 0 || Main.netMode == 1 || (double)projectile.localAI[1] != 0.0) { return; } Vector2 v = projectile.ai[0].ToRotationVector2().RotatedBy((double)Main.rand.Next(-1, 1) * 1.04719758033752 / 3.0, new Vector2()) * projectile.velocity.Length(); int index = Projectile.NewProjectile(projectile.Center.X - v.X, projectile.Center.Y - v.Y, v.X, v.Y, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, v.ToRotation() + 1000f, projectile.ai[1]); Main.projectile[index].timeLeft = 240; } }
public override void AI() { float rand = Main.rand.Next(90, 111) * 0.01f * (Main.essScale * 0.5f); Lighting.AddLight(projectile.Center, 0.5f * rand, 0.1f * rand, 0.1f * rand); if (projectile.localAI[0] == 0) { projectile.localAI[0] = 1; projectile.ai[0] = -1; } if (projectile.ai[0] >= 0 && projectile.ai[0] < 200) { int ai0 = (int)projectile.ai[0]; if (Main.npc[ai0].CanBeChasedBy()) { if (projectile.localAI[1] < 0.16f) { float rotation = projectile.velocity.ToRotation(); Vector2 vel = Main.npc[ai0].Center - projectile.Center; float targetAngle = vel.ToRotation(); projectile.localAI[1] += 1f / 1500f; projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(rotation.AngleLerp(targetAngle, projectile.localAI[1])); } else //eventually just switch to direct aim { projectile.velocity = projectile.DirectionTo(Main.npc[ai0].Center) * projectile.velocity.Length(); } } else { projectile.ai[0] = -1f; projectile.netUpdate = true; } } else { if (--projectile.ai[1] < 0f) { projectile.ai[1] = 6f; float maxDistance = 1700f; int possibleTarget = -1; for (int i = 0; i < 200; i++) { NPC npc = Main.npc[i]; if (npc.CanBeChasedBy()) { float npcDistance = projectile.Distance(npc.Center); if (npcDistance < maxDistance) { maxDistance = npcDistance; possibleTarget = i; } } } projectile.ai[0] = possibleTarget; projectile.netUpdate = true; } projectile.localAI[1] = 0; } projectile.rotation = projectile.velocity.ToRotation() - (float)Math.PI / 2; }
public override void AI() { if (projectile.timeLeft < 60 * (projectile.extraUpdates + 1)) //stop homing { return; } if (targetID == -1) //no target atm { if (searchTimer == 0) //search every few ticks { searchTimer = 6; int possibleTarget = -1; float closestDistance = 500f; for (int i = 0; i < 200; i++) { NPC npc = Main.npc[i]; if (npc.active && npc.chaseable && npc.lifeMax > 5 && !npc.dontTakeDamage && !npc.friendly && !npc.immortal) { float distance = Vector2.Distance(projectile.Center, npc.Center); if (closestDistance > distance) { closestDistance = distance; possibleTarget = i; } } } if (possibleTarget != -1) { targetID = possibleTarget; projectile.netUpdate = true; } } searchTimer--; } else //currently have target { NPC npc = Main.npc[targetID]; if (npc.active && npc.chaseable && !npc.dontTakeDamage && npc.immune[projectile.owner] == 0) //target is still valid { Vector2 distance = npc.Center - projectile.Center; double angle = distance.ToRotation() - projectile.velocity.ToRotation(); if (angle > Math.PI) { angle -= 2.0 * Math.PI; } if (angle < -Math.PI) { angle += 2.0 * Math.PI; } if (projectile.ai[0] == -1) { if (Math.Abs(angle) > Math.PI * 0.75) { projectile.velocity = projectile.velocity.RotatedBy(angle * 0.07); } else { float range = distance.Length(); float difference = 12.7f / range; distance *= difference; distance /= 7f; projectile.velocity += distance; if (range > 70f) { projectile.velocity *= 0.977f; } } } else { projectile.velocity = projectile.velocity.RotatedBy(angle * 0.1); } } else //target lost, reset { targetID = -1; searchTimer = 0; projectile.netUpdate = true; } } }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture; Vector2 origin; Vector2 drawPos; float laserAlpha = 0f; if (timer > 120) { laserAlpha = 1f; } else if (Math.Abs(timer - 60) < 20) { laserAlpha = (20f - Math.Abs(timer - 60)) / 40f; } else if (timer > 100) { laserAlpha = (timer - 100) / 20f; } if (laserAlpha > 0f) { texture = mod.GetTexture("ChaosSpirit/DissonanceRay"); Color color = Color.White * laserAlpha; origin = new Vector2(texture.Width / 2, texture.Height / 2); int other = Main.projectileIdentity[projectile.owner, (int)projectile.ai[1]]; if (other >= 0) { Vector2 laserTarget = Main.projectile[other].Center; Vector2 direction = laserTarget - projectile.Center; float length = direction.Length(); direction.Normalize(); float rotation = direction.ToRotation(); for (float k = 8f; k < length; k += 16f) { drawPos = projectile.Center + k * direction - Main.screenPosition; float useRotation = rotation; if (Main.rand.Next(2) == 0) { useRotation += MathHelper.Pi; } spriteBatch.Draw(texture, drawPos, null, color, useRotation, origin, 1f, SpriteEffects.None, 0f); } } { Vector2 direction = projectile.ai[0].ToRotationVector2(); float length = 2400f; float rotation = projectile.ai[0]; for (float k = 8f; k < length; k += 16f) { drawPos = projectile.Center + k * direction - Main.screenPosition; float useRotation = rotation; if (Main.rand.Next(2) == 0) { useRotation += MathHelper.Pi; } spriteBatch.Draw(texture, drawPos, null, color, useRotation, origin, 1f, SpriteEffects.None, 0f); } } } texture = Main.projectileTexture[projectile.type]; drawPos = projectile.Center - Main.screenPosition; origin = new Vector2(texture.Width / 2, texture.Height / 2); spriteBatch.Draw(texture, drawPos, null, Color.White, projectile.rotation, origin, 0.5f, SpriteEffects.None, 0f); spriteBatch.Draw(texture, drawPos, null, Color.White, -projectile.rotation, origin, 0.5f, SpriteEffects.None, 0f); spriteBatch.Draw(texture, drawPos, null, Color.White, -projectile.rotation, origin, 1f, SpriteEffects.None, 0f); spriteBatch.Draw(texture, drawPos, null, Color.White, projectile.rotation, origin, 1f, SpriteEffects.None, 0f); return(false); }
public override void AI() { Projectile.alpha += Projectile.timeLeft > 51 ? -10 : 10; if (Projectile.alpha < 0) { Projectile.alpha = 0; } if (Projectile.alpha > 255) { Projectile.alpha = 255; } if (Projectile.timeLeft % 30 == 0) { /*const int max = 5; * int[] nums = new int[max]; * float[] dist = new float[max]; * int j = 0; * int farthest = 0; * float distance = 2000f; * for (int i = 0; i < 200; i++) //find the five closest npcs * { * if (Main.npc[i].CanBeChasedBy()) * { * float newDist = Vector2.Distance(Main.npc[i].Center, Projectile.Center); * if (newDist < distance && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) * { * if (j >= max) //found an npc closer than the farthest tracked npc * { * nums[farthest] = i; //replace farthest with this npc * dist[farthest] = newDist; * for (int k = 0; k < 5; k++) //update farthest to track the actual farthest npc * if (dist[farthest] < dist[k]) * farthest = k; * } * else //haven't filled array yet, accept anyone * { * nums[j] = i; //track npc's id * dist[j] = newDist; //track npc's distance * j++; * if (j == 5) //array is full now * { * for (int k = 0; k < max; k++) //keep track of npc w/ highest distance * if (dist[farthest] < dist[k]) * farthest = k; * distance = dist[farthest]; //now only accepting npcs closer than the farthest tracked npc * } * } * } * } * } * for (int i = 0; i < j; i++) * { * Vector2 dir = Main.npc[nums[i]].Center - Projectile.Center; * float ai1 = Main.rand.Next(100); * Vector2 vel = Vector2.Normalize(dir.RotatedByRandom(Math.PI / 4)) * 7f; * Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType<LunarCultistLightningArc>(), Projectile.damage, Projectile.knockBack / 2, Projectile.owner, dir.ToRotation(), ai1); * //Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel, ProjectileID.CultistBossLightningOrbArc, Projectile.damage, Projectile.knockBack / 2, Projectile.owner, dir.ToRotation(), ai1); * }*/ int cultistTarget = -1; Projectile cultist = FargoSoulsUtil.ProjectileExists(Projectile.ai[0], ModContent.ProjectileType <LunarCultist>()); if (cultist != null) { NPC cultistTargetNpc = FargoSoulsUtil.NPCExists(cultist.ai[0]); if (cultistTargetNpc != null) { cultistTarget = cultistTargetNpc.whoAmI; if (cultistTargetNpc.CanBeChasedBy() && Collision.CanHitLine(Projectile.Center, 0, 0, cultistTargetNpc.Center, 0, 0)) { Vector2 dir = cultistTargetNpc.Center - Projectile.Center; float ai1New = Main.rand.Next(100); Vector2 vel = Vector2.Normalize(dir.RotatedByRandom(Math.PI / 4)) * 7f; if (Projectile.owner == Main.myPlayer) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType <LunarCultistLightningArc>(), Projectile.damage, Projectile.knockBack / 2, Projectile.owner, dir.ToRotation(), ai1New); } } } } float maxDistance = 2000f; int possibleTarget = -1; foreach (NPC n in Main.npc.Where(n => n.CanBeChasedBy() && Collision.CanHitLine(Projectile.Center, 0, 0, n.Center, 0, 0))) { float npcDistance = Projectile.Distance(n.Center); if (npcDistance < maxDistance && n.whoAmI != cultistTarget) { maxDistance = npcDistance; possibleTarget = n.whoAmI; } } if (possibleTarget != -1) { Vector2 dir = Main.npc[possibleTarget].Center - Projectile.Center; float ai1 = Main.rand.Next(100); Vector2 vel = Vector2.Normalize(dir.RotatedByRandom(Math.PI / 4)) * 7f; if (Projectile.owner == Main.myPlayer) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType <LunarCultistLightningArc>(), Projectile.damage, Projectile.knockBack / 2, Projectile.owner, dir.ToRotation(), ai1); } } } Lighting.AddLight(Projectile.Center, 0.4f, 0.85f, 0.9f); Projectile.frameCounter++; if (Projectile.frameCounter > 3) { Projectile.frameCounter = 0; Projectile.frame++; if (Projectile.frame > 3) { Projectile.frame = 0; } } float num11 = (float)(Main.rand.NextDouble() * 1.0 - 0.5); //vanilla dust :echbegone: if ((double)num11 < -0.5) { num11 = -0.5f; } if ((double)num11 > 0.5) { num11 = 0.5f; } Vector2 vector21 = new Vector2((float)-Projectile.width * 0.2f * Projectile.scale, 0.0f).RotatedBy((double)num11 * 6.28318548202515, new Vector2()).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2()); int index21 = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 226, (float)(-(double)Projectile.velocity.X / 3.0), (float)(-(double)Projectile.velocity.Y / 3.0), 150, Color.Transparent, 0.7f); Main.dust[index21].position = Projectile.Center + vector21; Main.dust[index21].velocity = Vector2.Normalize(Main.dust[index21].position - Projectile.Center) * 2f; Main.dust[index21].noGravity = true; float num1 = (float)(Main.rand.NextDouble() * 1.0 - 0.5); if ((double)num1 < -0.5) { num1 = -0.5f; } if ((double)num1 > 0.5) { num1 = 0.5f; } Vector2 vector2 = new Vector2((float)-Projectile.width * 0.6f * Projectile.scale, 0.0f).RotatedBy((double)num1 * 6.28318548202515, new Vector2()).RotatedBy((double)Projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(Projectile.Center - Vector2.One * 5f, 10, 10, 226, (float)(-(double)Projectile.velocity.X / 3.0), (float)(-(double)Projectile.velocity.Y / 3.0), 150, Color.Transparent, 0.7f); Main.dust[index2].velocity = Vector2.Zero; Main.dust[index2].position = Projectile.Center + vector2; Main.dust[index2].noGravity = true; }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse == 2) { Vector2 mousePos = Main.MouseWorld; Vector2 unit = (player.Center - mousePos); Vector2 speed = new Vector2(speedX, speedY); double angle = ( ( ( player.itemAnimation - 7f ) / 14) * ( 1 / ( unit.Length() / 400 ) ) ); speed = speed.RotatedBy(angle); int a = Projectile.NewProjectile(position.X, position.Y, speed.X, speed.Y, type, damage, knockBack, player.whoAmI, (float)angle, 30); Main.projectile[a].magic = true; Main.projectile[a].friendly = true; Main.projectile[a].hostile = false; Main.projectile[a].penetrate = -1; Main.projectile[a].usesLocalNPCImmunity = true; unit.Normalize(); //unit *= 0.66f; player.velocity = player.velocity.Length() >= 12?new Vector2(player.velocity.Length(), 0).RotatedBy(MathHelper.Lerp(player.velocity.ToRotation(), unit.ToRotation(), 0.75f)):player.velocity + unit; return(false); } else { ElementalPlayer modPlayer = player.GetModPlayer <ElementalPlayer>(); damage = (int)(damage * 2.5f); if (player.controlUseItem) { player.itemAnimation = item.useAnimation - 1; modPlayer.channelsword = 5; } return(!modPlayer.FireWhip); } }
public override void AI() { //if (projectile.owner == null || projectile.owner < 0) //return; Player player = ThePlayer; int attackrate = 40; if (player.dead || !player.active) { player.ClearBuff(ModContent.BuffType <AutoclickerMinionBuff>()); } if (player.HasBuff(ModContent.BuffType <AutoclickerMinionBuff>())) { projectile.timeLeft = 2; } Vector2 there = player.Center; float dist = projectile.ai[1] < 1 ? 64 : 8f; projectile.localAI[0] += 1; projectile.ai[0] += 1; projectile.ai[1] -= 1; clickDelay -= 1; float id = 0f; float maxus = 0f; for (int i = 0; i < Main.maxProjectiles; i++) // Loop all projectiles { Projectile currentProjectile = Main.projectile[i]; if (currentProjectile.active && // Make sure the projectile is active currentProjectile.owner == Main.myPlayer && // Make sure the projectile's owner is the client's player currentProjectile.type == projectile.type) { // Make sure the projectile is of the same type as this javelin if (i == projectile.whoAmI) { id = maxus; } maxus += 1f; } } projectile.localAI[1] = id / maxus; NPC them = null; Entity focusOn = player; if (player.HasMinionAttackTargetNPC) { them = Main.npc[player.MinionAttackTargetNPC]; there = them.Center; focusOn = them; } else { List <NPC> enemies = SGAUtils.ClosestEnemies(projectile.Center, 2200, projectile.ai[1] > 0 ? projectile.Center : player.Center, checkWalls: false); if (enemies != null && enemies.Count > 0) { enemies = enemies.OrderBy(testby => testby.life).ToList(); them = enemies[(int)id % enemies.Count]; there = them.Center; focusOn = them; } } float angles = ((id / (float)maxus) * MathHelper.TwoPi) - player.SGAPly().timer / 150f; Vector2 here = new Vector2((float)Math.Cos(angles), (float)Math.Sin(angles)) * dist; Vector2 where = there + here; Vector2 todist = (where - projectile.Center); // +(focusOn != null ? focusOn.velocity : Vector2.Zero); Vector2 todistreal = (there - projectile.Center); float lookat = todist.ToRotation(); if (them == null) { lookat = (focusOn.Center - projectile.Center).ToRotation(); } if (todistreal.Length() > 0.01f) { if (todistreal.Length() > 600f) { projectile.velocity += Vector2.Normalize(todist) * MathHelper.Clamp(todist.Length() / 6f, 0f, 64f); projectile.velocity *= 0.940f; } else { projectile.Center += todist * (projectile.ai[1] > -(attackrate / (ClickerBoost ? 10f : 5f)) ? 0.25f : 0.98f); projectile.velocity *= 0.820f; } } if (projectile.velocity.Length() > 1f) { float maxspeed = Math.Min(projectile.velocity.Length(), 16 + (todist.Length() / 4f)); projectile.velocity.Normalize(); projectile.velocity *= maxspeed; } if (todistreal.Length() > 160f && (projectile.ai[1] < 0 || them == null)) { if (them != null) { lookat = 0; } projectile.rotation = projectile.rotation.AngleLerp(lookat, 0.05f); } else { lookat = (focusOn.Center - projectile.Center).ToRotation(); projectile.rotation = projectile.rotation.AngleLerp(lookat, 0.15f); if (them != null) { if (player.SGAPly().timer % (int)(attackrate * (ClickerBoost ? 0.5f : 1f)) == (int)(((id * (attackrate / maxus))) * (ClickerBoost ? 0.5f : 1f))) { DoClick(); } if (clickDelay == 0) { Main.PlaySound(SoundID.MenuTick, (int)projectile.Center.X, (int)projectile.Center.Y, 0); if (!them.IsDummy() && Main.rand.Next(500) < player.maxTurrets && player.HeldItem.type == ModContent.ItemType <Autoclicker>()) { bool cookieNearby = false; int range = 900 + (ClickerBoost ? 600 : 0); foreach (Item item in Main.item.Where(testby => testby.active && testby.type == ModContent.ItemType <ClickerCookie>() && (testby.Center - them.Center).LengthSquared() < (range * range))) { cookieNearby = true; } if (!cookieNearby) { Item.NewItem(them.Center, ModContent.ItemType <ClickerCookie>(), prefixGiven: PrefixID.Menacing, noGrabDelay: true); } } int damage = (int)(projectile.damage * (ClickerBoost ? 0.60f : 1f)); //them.SGANPCs().AddDamageStack(damage,60*5); Projectile.NewProjectile(them.Center, projectile.rotation.ToRotationVector2(), ModContent.ProjectileType <AutoclickerClickProj>(), damage, projectile.knockBack, projectile.owner); /*int damazz = (Main.DamageVar((float)projectile.damage)); * them.StrikeNPC(damazz, projectile.knockBack, them.direction, false, false); * player.addDPS(damazz); * if (Main.netMode != NetmodeID.SinglePlayer) * { * NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, them.whoAmI, damazz, 16f, (float)1, 0, 0, 0); * }*/ } } } projectile.velocity *= 0.96f; Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 0.78f); }
public override bool PreAI() { int dust = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107); Main.dust[dust].scale = 1.5f; Main.dust[dust].noGravity = true; projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; if (projectile.ai[0] == 0 && Main.netMode != NetmodeID.MultiplayerClient) { target = -1; float distance = 2000f; for (int k = 0; k < 255; k++) { if (Main.player[k].active && !Main.player[k].dead) { Vector2 center = Main.player[k].Center; float currentDistance = Vector2.Distance(center, projectile.Center); if (currentDistance < distance || target == -1) { distance = currentDistance; target = k; } } } if (target != -1) { projectile.ai[0] = 1; projectile.netUpdate = true; } } else if (target >= 0 && target < Main.maxPlayers) { Player targetPlayer = Main.player[target]; if (!targetPlayer.active || targetPlayer.dead) { target = -1; projectile.ai[0] = 0; projectile.netUpdate = true; } else { float currentRot = projectile.velocity.ToRotation(); Vector2 direction = targetPlayer.Center - projectile.Center; float targetAngle = direction.ToRotation(); if (direction == Vector2.Zero) { targetAngle = currentRot; } float desiredRot = currentRot.AngleLerp(targetAngle, 0.1f); projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(desiredRot); } } if (projectile.timeLeft <= 60) { projectile.alpha -= 4; } return(true); }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Vector2 vector = new Vector2(speedX, speedY); int L = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, mod.ProjectileType("ChaosLightning"), damage, knockBack, player.whoAmI, vector.ToRotation()); Main.projectile[L].penetrate = -1; Main.projectile[L].hostile = false; Main.projectile[L].friendly = true; Main.projectile[L].melee = true; Main.projectile[L].usesLocalNPCImmunity = true; Main.projectile[L].localNPCHitCooldown = -1; return(false); }
public override void AI() { int time = 15 * (int)Projectile.ai[1]; const int maxScale = 1; if (Projectile.ai[0] == 0) { p = Player.FindClosest(Projectile.Center, 0, 0); } if (p != -1) { Projectile.position += Main.player[p].velocity * 0.8f; Vector2 target = Main.player[p].Center; target.Y -= 400; Vector2 distance = target - Projectile.Center; distance /= 6f; Projectile.velocity = (Projectile.velocity * 19f + distance) / 20f; } Projectile.ai[0]++; if (Projectile.ai[0] <= 30) { if (Main.rand.NextBool(4)) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515); Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)]; dust.noGravity = true; dust.position = Projectile.Center - spinningpoint * Main.rand.Next(10, 21); dust.velocity = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 4f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; } if (Main.rand.NextBool(4)) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515); Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)]; dust.noGravity = true; dust.position = Projectile.Center - spinningpoint * 30f; dust.velocity = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 2f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; } } else if (Projectile.ai[0] <= 60) { Projectile.scale = (Projectile.ai[0] - 30) / 40 * maxScale; Projectile.alpha = 255 - (int)(255 * Projectile.scale / maxScale); Projectile.rotation = Projectile.rotation - 0.1570796f; if (Main.rand.NextBool()) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale; Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)]; dust.noGravity = true; dust.position = Projectile.Center - spinningpoint * Main.rand.Next(10, 21); dust.velocity = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 6f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = Projectile.Center; } if (Main.rand.NextBool()) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale; Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)]; dust.noGravity = true; dust.position = Projectile.Center - spinningpoint * 30f; dust.velocity = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 3f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = Projectile.Center; } } else if (Projectile.ai[0] <= 60 + time) { Projectile.scale = maxScale; Projectile.alpha = 0; Projectile.rotation = Projectile.rotation - (float)Math.PI / 60f; if (Main.rand.NextBool()) { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale; Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)]; dust.noGravity = true; dust.position = Projectile.Center - spinningpoint * Main.rand.Next(10, 21); dust.velocity = spinningpoint.RotatedBy(1.57079637050629, new Vector2()) * 6f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = Projectile.Center; } else { Vector2 spinningpoint = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale; Dust dust = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)]; dust.noGravity = true; dust.position = Projectile.Center - spinningpoint * 30f; dust.velocity = spinningpoint.RotatedBy(-1.57079637050629, new Vector2()) * 3f; dust.scale = 0.5f + Main.rand.NextFloat(); dust.fadeIn = 0.5f; dust.customData = Projectile.Center; } if (Projectile.ai[0] == 60 + time) //shoot lightning out { SoundEngine.PlaySound(SoundID.Item82, Projectile.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 dir = Vector2.UnitY; float ai1New = Main.rand.Next(100); Vector2 vel = Vector2.Normalize(dir.RotatedByRandom(Math.PI / 4)) * 5f; Projectile.NewProjectile(Terraria.Entity.InheritSource(Projectile), Projectile.Center, vel, ProjectileID.CultistBossLightningOrbArc, Projectile.damage, 0, Main.myPlayer, dir.ToRotation(), ai1New); } } } else { Projectile.scale = (float)(1.0 - (Projectile.ai[0] - time) / 60.0) * maxScale; Projectile.alpha = 255 - (int)(255 * Projectile.scale / maxScale); Projectile.rotation = Projectile.rotation - (float)Math.PI / 30f; if (Projectile.alpha >= 255) { Projectile.Kill(); } for (int index = 0; index < 2; ++index) { switch (Main.rand.Next(3)) { case 0: Vector2 spinningpoint1 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale; Dust dust1 = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint1 * 30f, 0, 0, 229, 0.0f, 0.0f, 0, new Color(), 1f)]; dust1.noGravity = true; dust1.position = Projectile.Center - spinningpoint1 * Main.rand.Next(10, 21); dust1.velocity = spinningpoint1.RotatedBy(1.57079637050629, new Vector2()) * 6f; dust1.scale = 0.5f + Main.rand.NextFloat(); dust1.fadeIn = 0.5f; dust1.customData = Projectile.Center; break; case 1: Vector2 spinningpoint2 = Vector2.UnitY.RotatedByRandom(6.28318548202515) * Projectile.scale; Dust dust2 = Main.dust[Dust.NewDust(Projectile.Center - spinningpoint2 * 30f, 0, 0, 240, 0.0f, 0.0f, 0, new Color(), 1f)]; dust2.noGravity = true; dust2.position = Projectile.Center - spinningpoint2 * 30f; dust2.velocity = spinningpoint2.RotatedBy(-1.57079637050629, new Vector2()) * 3f; dust2.scale = 0.5f + Main.rand.NextFloat(); dust2.fadeIn = 0.5f; dust2.customData = Projectile.Center; break; } } } Dust dust3 = Main.dust[Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 229, 0f, 0f, 0, new Color(), 1f)]; dust3.velocity *= 5f; dust3.fadeIn = 1f; dust3.scale = 1f + Main.rand.NextFloat() + Main.rand.Next(4) * 0.3f; dust3.noGravity = true; }
public override bool PreAI() { if (npc.ai[1] == 0f) { npc.ai[1] = 1f; Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 34); } else if (npc.ai[1] == 1f && Main.netMode != NetmodeID.MultiplayerClient) { int target = -1; float distance = 2000f; for (int k = 0; k < 255; k++) { if (Main.player[k].active && !Main.player[k].dead) { Vector2 center = Main.player[k].Center; float currentDistance = Vector2.Distance(center, npc.Center); if ((currentDistance < distance || target == -1) && Collision.CanHit(npc.Center, 1, 1, center, 1, 1)) { distance = currentDistance; target = k; } } } if (target != -1) { npc.ai[1] = 21f; npc.ai[0] = target; npc.netUpdate = true; } } else if (npc.ai[1] > 20f && npc.ai[1] < 200f) { npc.ai[1] += 1f; int target = (int)npc.ai[0]; if (!Main.player[target].active || Main.player[target].dead) { npc.ai[1] = 1f; npc.ai[0] = 0f; npc.netUpdate = true; } else { float num6 = npc.velocity.ToRotation(); Vector2 vector2 = Main.player[target].Center - npc.Center; float targetAngle = vector2.ToRotation(); if (vector2 == Vector2.Zero) { targetAngle = num6; } float num7 = num6.AngleLerp(targetAngle, 0.008f); npc.velocity = new Vector2(npc.velocity.Length(), 0f).RotatedBy((double)num7, default(Vector2)); } } if (npc.ai[1] >= 1f && npc.ai[1] < 20f) { npc.ai[1] += 1f; if (npc.ai[1] == 20f) { npc.ai[1] = 1f; } } if (npc.alpha <= 0) { npc.alpha = 0; } else { npc.alpha -= 40; } npc.spriteDirection = npc.direction; npc.localAI[0] += 1f; if (npc.localAI[0] == 12f) { npc.localAI[0] = 0f; for (int j = 0; j < 12; j++) { Vector2 vector2 = Vector2.UnitX * -npc.width / 2f; vector2 += -Utils.RotatedBy(Vector2.UnitY, ((float)j * 3.141591734f / 6f), default(Vector2)) * new Vector2(8f, 16f); vector2 = Utils.RotatedBy(vector2, (npc.rotation - 1.57079637f), default(Vector2)); int num8 = Dust.NewDust(npc.Center, 0, 0, 173, 0f, 0f, 160, default(Color), 1f); Main.dust[num8].scale = 1.1f; Main.dust[num8].noGravity = true; Main.dust[num8].position = npc.Center + vector2; Main.dust[num8].velocity = npc.velocity * 0.1f; Main.dust[num8].velocity = Vector2.Normalize(npc.Center - npc.velocity * 3f - Main.dust[num8].position) * 1.25f; } } Vector2 position = npc.Center + Vector2.Normalize(npc.velocity) * 10; Dust newDust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f)]; newDust.position = position; newDust.velocity = npc.velocity.RotatedBy(Math.PI / 2, default(Vector2)) * 0.33F + npc.velocity / 4; newDust.position += npc.velocity.RotatedBy(Math.PI / 2, default(Vector2)); newDust.fadeIn = 0.5f; newDust.noGravity = true; newDust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1)]; newDust.position = position; newDust.velocity = npc.velocity.RotatedBy(-Math.PI / 2, default(Vector2)) * 0.33F + npc.velocity / 4; newDust.position += npc.velocity.RotatedBy(-Math.PI / 2, default(Vector2)); newDust.fadeIn = 0.5F; newDust.noGravity = true; for (int index1 = 0; index1 < 6; ++index1) { float x = (npc.Center.X - 2); float xnum2 = (npc.Center.X + 2); float y = (npc.Center.Y); if (npc.direction == -1) { int index2 = Dust.NewDust(new Vector2(x, y), 1, 1, 173, 0.0f, 0.0f, 0, new Color(), 1f); Main.dust[index2].position.X = x; Main.dust[index2].position.Y = y; Main.dust[index2].scale = .85f; Main.dust[index2].velocity *= 0.02f; Main.dust[index2].noGravity = true; Main.dust[index2].noLight = false; } else if (npc.direction == 1) { int index2 = Dust.NewDust(new Vector2(xnum2, y), 1, 1, 173, 0.0f, 0.0f, 0, new Color(), 1f); Main.dust[index2].position.X = xnum2; Main.dust[index2].position.Y = y; Main.dust[index2].scale = .85f; Main.dust[index2].velocity *= 0.02f; Main.dust[index2].noGravity = true; Main.dust[index2].noLight = false; } } Lighting.AddLight(npc.Center, 1.1f, 0.3f, 1.1f); return(false); }
public override void AI() { //QwertyMethods.ServerClientCheck(timer); Player player = Main.player[npc.target]; npc.chaseable = false; if (npc.ai[3] > 10) { npc.chaseable = true; } else { for (int i = 0; i < Main.player.Length; i++) { if ((Main.player[i].active && (QwertysRandomContent.LocalCursor[i] - npc.Center).Length() < 180) || (Main.player[i].Center - npc.Center).Length() < orbitDistance) { npc.chaseable = true; break; } } } npc.TargetClosest(false); pupilDirection = (player.Center - npc.Center).ToRotation(); pulseCounter += (float)Math.PI / 30; npc.scale = 1f + .05f * (float)Math.Sin(pulseCounter); pupilStareOutAmount = (player.Center - npc.Center).Length() / 300f; if (pupilStareOutAmount > 1f) { pupilStareOutAmount = 1f; } blinkCounter--; if (blinkCounter < 0 && attackType != 1) { if (blinkCounter % 10 == 0) { if (frame == 7) { blinkCounter = Main.rand.Next(180, 240); } else { frame++; } } } else { frame = 0; } if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!player.active || player.dead) { canDespawn = true; npc.velocity = new Vector2(0f, 10f); if (npc.timeLeft > 10) { npc.timeLeft = 10; } return; } } else { canDespawn = false; if ((cloak == null || cloak.type != mod.ProjectileType("Cloak") || !cloak.active) && Main.netMode != 1) { cloak = Main.projectile[Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Cloak"), 0, 0, Main.myPlayer, npc.whoAmI)]; } if (playerviewRadius > 80) { playerviewRadius -= 10; } if (Main.netMode != 1) { cloak.ai[1] = playerviewRadius; cloak.timeLeft = 2; } if (myWall != null) { myWall.timeLeft = 2; } if (npc.ai[3] > 0) { npc.ai[3]--; } if (attackType != 0) { timer++; if (player.velocity.Length() > 0f) { lastMoved = player.velocity; } } switch (attackType) { case -1: if (timer > 120 * (Main.expertMode ? .2f + .8f * ((float)npc.life / npc.lifeMax) : 1f) && (player.Center - npc.Center).Length() < 1000f) { if (Main.netMode != 1) { attackType = Main.rand.Next(7); switch (attackType) { default: orbitalVelocity = 14f; if (Main.rand.Next(2) == 0) { orbitalVelocity *= -1; } break; case 0: orbitalVelocity = defaultOrbitalSpeed() * 4f; break; case 1: orbitalVelocity = 0; Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Warning"), 0, 0f, Main.myPlayer, 0, 0); if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/Notice").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } npc.velocity = Vector2.Zero; break; } npc.netUpdate = true; } timer = 0; } break; default: if (timer >= 60) { orbitalVelocity = defaultOrbitalSpeed(); timer = 0; attackType = -1; } else if (timer % 15 == 0 && Main.netMode != 1) { Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("EtimsicCannon"), Main.expertMode ? 18 : 24, 0f, Main.myPlayer, (player.Center - npc.Center).ToRotation()); Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Warning"), 0, 0f, Main.myPlayer, 1, (player.Center - npc.Center).ToRotation()); if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/Notice").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } } break; case 0: if (timer == 0 && QwertyMethods.AngularDifference(lastMoved.ToRotation(), (npc.Center - player.Center).ToRotation()) < (float)Math.PI / 30) { if (Main.netMode != 1) { myWall = Main.projectile[Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("EtimsicWall"), Main.expertMode ? 24 : 36, 0f, Main.myPlayer, (player.Center - npc.Center).ToRotation() + (float)Math.PI / 2)]; Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Warning"), 0, 0f, Main.myPlayer, 2, (player.Center - npc.Center).ToRotation() + (float)Math.PI / 2); } if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/Notice").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } timer = 1; npc.netUpdate = true; } if (timer > 0) { timer++; } if (timer >= 60) { orbitalVelocity = defaultOrbitalSpeed(); npc.netUpdate = true; timer = 0; attackType = -1; } break; case 1: if (timer > 60) { npc.ai[3] = 80; if (timer < 180 && timer % 15 == 0) { npc.velocity = Vector2.Zero; if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center + new Vector2((float)Math.Cos(pupilDirection) * greaterPupilRadius * pupilStareOutAmount, (float)Math.Sin(pupilDirection) * lesserPupilRadius) * npc.scale, QwertyMethods.PolarVector(10, pupilDirection), mod.ProjectileType("EtimsicRay"), Main.expertMode ? 18 : 24, 0f, Main.myPlayer); } if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/PewPew").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } } if (timer == 179 && Main.netMode != 1) { npc.netUpdate = true; } if (timer == 180) { npc.velocity = QwertyMethods.PolarVector(15, (player.Center - npc.Center).ToRotation()); npc.netUpdate = true; } if (timer > 240) { npc.netUpdate = true; orbitalVelocity = defaultOrbitalSpeed(); timer = 0; attackType = -1; } } break; } //movement if (attackType == 1) { } else { npc.velocity = QwertyMethods.PolarVector(orbitalVelocity, (player.Center - npc.Center).ToRotation() + (float)Math.PI / 2); if ((player.Center - npc.Center).Length() < orbitDistance - 50) { npc.velocity += QwertyMethods.PolarVector(-retreatApproachSpeed, (player.Center - npc.Center).ToRotation()); } else if ((player.Center - npc.Center).Length() > orbitDistance + 50) { npc.velocity += QwertyMethods.PolarVector(retreatApproachSpeed, (player.Center - npc.Center).ToRotation()); } } } }
public override void AI() { alphaCounter += 0.08f; Player player = Main.player[projectile.owner]; if (!released) { projectile.scale = MathHelper.Clamp(projectile.ai[0] / 10, 0, 1); } if (player.direction == 1) { radians += (double)((projectile.ai[0] + 10) / 200); } else { radians -= (double)((projectile.ai[0] + 10) / 200); } if (radians > 6.28) { radians -= 6.28; } if (radians < -6.28) { radians += 6.28; } projectile.velocity = Vector2.Zero; if (projectile.ai[0] % 20 == 0) { Main.PlaySound(new LegacySoundStyle(SoundID.Item, 19).WithPitchVariance(0.1f).WithVolume(0.5f), projectile.Center); } if (projectile.ai[0] < chargeTime) { projectile.ai[0] += chargeRate; if (projectile.ai[0] >= chargeTime) { Main.PlaySound(SoundID.NPCDeath7, projectile.Center); } } Vector2 direction = Main.MouseWorld - player.position; direction.Normalize(); double throwingAngle = direction.ToRotation() + 3.14; projectile.position = player.Center - (Vector2.UnitX.RotatedBy(radians) * 40) - (projectile.Size / 2); player.itemTime = 4; player.itemAnimation = 4; player.itemRotation = MathHelper.WrapAngle((float)radians); if (player.whoAmI == Main.myPlayer) { player.ChangeDir(Math.Sign(direction.X)); } if (player.direction != 1) { throwingAngle -= 6.28; } if (!player.channel || released) { if (projectile.ai[0] < chargeTime || released) { released = true; projectile.scale -= 0.15f; if (projectile.scale < 0.15f) { projectile.active = false; } } else { projectile.active = false; direction *= throwSpeed; Projectile.NewProjectile(player.Center, direction, thrownProj, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner); } } }
public void Update() { if (Main.netMode == 2) { return; } if (this.active) { if (this.type >= 276 && this.type <= 282) { this.velocity.X = this.velocity.X * 0.98f; this.velocity.Y = this.velocity.Y * 0.98f; if (this.velocity.Y < this.scale) { this.velocity.Y = this.velocity.Y + 0.05f; } if ((double)this.velocity.Y > 0.1) { if (this.velocity.X > 0f) { this.rotation += 0.01f; } else { this.rotation -= 0.01f; } } } if (this.type >= 570 && this.type <= 572) { this.scale -= 0.001f; if ((double)this.scale <= 0.01) { this.scale = 0.01f; Gore.goreTime = 0; } this.sticky = false; this.rotation = this.velocity.X * 0.1f; } else if (this.type >= 706 && this.type <= 717) { if ((double)this.position.Y < Main.worldSurface * 16.0 + 8.0) { this.alpha = 0; } else { this.alpha = 100; } int num = 4; this.frameCounter += 1; if (this.frame <= 4) { int num2 = (int)(this.position.X / 16f); int num3 = (int)(this.position.Y / 16f) - 1; if (WorldGen.InWorld(num2, num3, 0) && !Main.tile[num2, num3].active()) { this.active = false; } if (this.frame == 0) { num = 24 + Main.rand.Next(256); } if (this.frame == 1) { num = 24 + Main.rand.Next(256); } if (this.frame == 2) { num = 24 + Main.rand.Next(256); } if (this.frame == 3) { num = 24 + Main.rand.Next(96); } if (this.frame == 5) { num = 16 + Main.rand.Next(64); } if (this.type == 716) { num *= 2; } if (this.type == 717) { num *= 4; } if ((int)this.frameCounter >= num) { this.frameCounter = 0; this.frame += 1; if (this.frame == 5) { int num4 = Gore.NewGore(this.position, this.velocity, this.type, 1f); Main.gore[num4].frame = 9; Main.gore[num4].velocity *= 0f; } } } else if (this.frame <= 6) { num = 8; if (this.type == 716) { num *= 2; } if (this.type == 717) { num *= 3; } if ((int)this.frameCounter >= num) { this.frameCounter = 0; this.frame += 1; if (this.frame == 7) { this.active = false; } } } else if (this.frame <= 9) { num = 6; if (this.type == 716) { num = (int)((double)num * 1.5); this.velocity.Y = this.velocity.Y + 0.175f; } else if (this.type == 717) { num *= 2; this.velocity.Y = this.velocity.Y + 0.15f; } else { this.velocity.Y = this.velocity.Y + 0.2f; } if ((double)this.velocity.Y < 0.5) { this.velocity.Y = 0.5f; } if (this.velocity.Y > 12f) { this.velocity.Y = 12f; } if ((int)this.frameCounter >= num) { this.frameCounter = 0; this.frame += 1; } if (this.frame > 9) { this.frame = 7; } } else { if (this.type == 716) { num *= 2; } else if (this.type == 717) { num *= 6; } this.velocity.Y = this.velocity.Y + 0.1f; if ((int)this.frameCounter >= num) { this.frameCounter = 0; this.frame += 1; } this.velocity *= 0f; if (this.frame > 14) { this.active = false; } } } else if (this.type == 11 || this.type == 12 || this.type == 13 || this.type == 61 || this.type == 62 || this.type == 63 || this.type == 99 || this.type == 220 || this.type == 221 || this.type == 222 || (this.type >= 375 && this.type <= 377) || (this.type >= 435 && this.type <= 437) || (this.type >= 861 && this.type <= 862)) { this.velocity.Y = this.velocity.Y * 0.98f; this.velocity.X = this.velocity.X * 0.98f; this.scale -= 0.007f; if ((double)this.scale < 0.1) { this.scale = 0.1f; this.alpha = 255; } } else if (this.type == 16 || this.type == 17) { this.velocity.Y = this.velocity.Y * 0.98f; this.velocity.X = this.velocity.X * 0.98f; this.scale -= 0.01f; if ((double)this.scale < 0.1) { this.scale = 0.1f; this.alpha = 255; } } else if (this.type == 331) { this.alpha += 5; this.velocity.Y = this.velocity.Y * 0.95f; this.velocity.X = this.velocity.X * 0.95f; this.rotation = this.velocity.X * 0.1f; } else if (this.type != 860 && this.type != 892 && this.type != 893 && (this.type < 825 || this.type > 827) && (this.type < 411 || this.type > 430)) { this.velocity.Y = this.velocity.Y + 0.2f; } this.rotation += this.velocity.X * 0.1f; if (this.type >= 580 && this.type <= 582) { this.rotation = 0f; this.velocity.X = this.velocity.X * 0.95f; } if (this.type >= 825 && this.type <= 827) { if (this.timeLeft < 60) { this.alpha += Main.rand.Next(1, 7); } else if (this.alpha > 100) { this.alpha -= Main.rand.Next(1, 4); } if (this.alpha < 0) { this.alpha = 0; } if (this.alpha > 255) { this.timeLeft = 0; } this.velocity.X = (this.velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f; float num5 = 0f; if (this.velocity.X < 0f) { num5 = this.velocity.X * 0.2f; } this.velocity.Y = (this.velocity.Y * 50f + -0.35f + num5 + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f; this.rotation = this.velocity.X * 0.6f; float num6 = -1f; if (Main.goreLoaded[this.type]) { Rectangle rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((float)Main.goreTexture[this.type].Width * this.scale), (int)((float)Main.goreTexture[this.type].Height * this.scale)); for (int i = 0; i < 255; i++) { if (Main.player[i].active && !Main.player[i].dead) { Rectangle value = new Rectangle((int)Main.player[i].position.X, (int)Main.player[i].position.Y, Main.player[i].width, Main.player[i].height); if (rectangle.Intersects(value)) { this.timeLeft = 0; num6 = Main.player[i].velocity.Length(); break; } } } } if (this.timeLeft > 0) { if (Main.rand.Next(2) == 0) { this.timeLeft--; } if (Main.rand.Next(50) == 0) { this.timeLeft -= 5; } if (Main.rand.Next(100) == 0) { this.timeLeft -= 10; } } else { this.alpha = 255; if (Main.goreLoaded[this.type] && num6 != -1f) { float num7 = (float)Main.goreTexture[this.type].Width * this.scale * 0.8f; float x = this.position.X; float y = this.position.Y; float num8 = (float)Main.goreTexture[this.type].Width * this.scale; float num9 = (float)Main.goreTexture[this.type].Height * this.scale; int num10 = 31; int num11 = 0; while ((float)num11 < num7) { int num12 = Dust.NewDust(new Vector2(x, y), (int)num8, (int)num9, num10, 0f, 0f, 0, default(Color), 1f); Main.dust[num12].velocity *= (1f + num6) / 3f; Main.dust[num12].noGravity = true; Main.dust[num12].alpha = 100; Main.dust[num12].scale = this.scale; num11++; } } } } if (this.type >= 411 && this.type <= 430) { this.alpha = 50; this.velocity.X = (this.velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f; this.velocity.Y = (this.velocity.Y * 50f + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f; this.rotation = this.velocity.X * 0.3f; if (Main.goreLoaded[this.type]) { Rectangle rectangle2 = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((float)Main.goreTexture[this.type].Width * this.scale), (int)((float)Main.goreTexture[this.type].Height * this.scale)); for (int j = 0; j < 255; j++) { if (Main.player[j].active && !Main.player[j].dead) { Rectangle value2 = new Rectangle((int)Main.player[j].position.X, (int)Main.player[j].position.Y, Main.player[j].width, Main.player[j].height); if (rectangle2.Intersects(value2)) { this.timeLeft = 0; } } } if (Collision.SolidCollision(this.position, (int)((float)Main.goreTexture[this.type].Width * this.scale), (int)((float)Main.goreTexture[this.type].Height * this.scale))) { this.timeLeft = 0; } } if (this.timeLeft > 0) { if (Main.rand.Next(2) == 0) { this.timeLeft--; } if (Main.rand.Next(50) == 0) { this.timeLeft -= 5; } if (Main.rand.Next(100) == 0) { this.timeLeft -= 10; } } else { this.alpha = 255; if (Main.goreLoaded[this.type]) { float num13 = (float)Main.goreTexture[this.type].Width * this.scale * 0.8f; float x2 = this.position.X; float y2 = this.position.Y; float num14 = (float)Main.goreTexture[this.type].Width * this.scale; float num15 = (float)Main.goreTexture[this.type].Height * this.scale; int num16 = 176; if (this.type >= 416 && this.type <= 420) { num16 = 177; } if (this.type >= 421 && this.type <= 425) { num16 = 178; } if (this.type >= 426 && this.type <= 430) { num16 = 179; } int num17 = 0; while ((float)num17 < num13) { int num18 = Dust.NewDust(new Vector2(x2, y2), (int)num14, (int)num15, num16, 0f, 0f, 0, default(Color), 1f); Main.dust[num18].noGravity = true; Main.dust[num18].alpha = 100; Main.dust[num18].scale = this.scale; num17++; } } } } else if (this.type != 860 && this.type != 892 && this.type != 893) { if (this.type >= 706 && this.type <= 717) { if (this.type == 716) { float num19 = 0.6f; if (this.frame == 0) { num19 *= 0.1f; } else if (this.frame == 1) { num19 *= 0.2f; } else if (this.frame == 2) { num19 *= 0.3f; } else if (this.frame == 3) { num19 *= 0.4f; } else if (this.frame == 4) { num19 *= 0.5f; } else if (this.frame == 5) { num19 *= 0.4f; } else if (this.frame == 6) { num19 *= 0.2f; } else if (this.frame <= 9) { num19 *= 0.5f; } else if (this.frame == 10) { num19 *= 0.5f; } else if (this.frame == 11) { num19 *= 0.4f; } else if (this.frame == 12) { num19 *= 0.3f; } else if (this.frame == 13) { num19 *= 0.2f; } else if (this.frame == 14) { num19 *= 0.1f; } else { num19 = 0f; } float r = 1f * num19; float g = 0.5f * num19; float b = 0.1f * num19; Lighting.AddLight(this.position + new Vector2(8f, 8f), r, g, b); } Vector2 value3 = this.velocity; this.velocity = Collision.TileCollision(this.position, this.velocity, 16, 14, false, false, 1); if (this.velocity != value3) { if (this.frame < 10) { this.frame = 10; this.frameCounter = 0; if (this.type != 716 && this.type != 717) { Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, Main.rand.Next(2)); } } } else if (Collision.WetCollision(this.position + this.velocity, 16, 14)) { if (this.frame < 10) { this.frame = 10; this.frameCounter = 0; if (this.type != 716 && this.type != 717) { Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, 2); } } int num20 = (int)(this.position.X + 8f) / 16; int num21 = (int)(this.position.Y + 14f) / 16; if (Main.tile[num20, num21] != null && Main.tile[num20, num21].liquid > 0) { this.velocity *= 0f; this.position.Y = (float)(num21 * 16 - (int)(Main.tile[num20, num21].liquid / 16)); } } } else if (this.sticky) { int num22 = 32; if (Main.goreLoaded[this.type]) { num22 = Main.goreTexture[this.type].Width; if (Main.goreTexture[this.type].Height < num22) { num22 = Main.goreTexture[this.type].Height; } } num22 = (int)((float)num22 * 0.9f); this.velocity = Collision.TileCollision(this.position, this.velocity, (int)((float)num22 * this.scale), (int)((float)num22 * this.scale), false, false, 1); if (this.velocity.Y == 0f) { this.velocity.X = this.velocity.X * 0.97f; if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01) { this.velocity.X = 0f; } } if (this.timeLeft > 0) { this.timeLeft--; } else { this.alpha++; } } else { this.alpha += 2; } } if (this.type == 860 || this.type == 892 || this.type == 893) { if (this.velocity.Y < 0f) { Vector2 vector = new Vector2(this.velocity.X, 0.6f); int num23 = 32; if (Main.goreLoaded[this.type]) { num23 = Main.goreTexture[this.type].Width; if (Main.goreTexture[this.type].Height < num23) { num23 = Main.goreTexture[this.type].Height; } } num23 = (int)((float)num23 * 0.9f); vector = Collision.TileCollision(this.position, vector, (int)((float)num23 * this.scale), (int)((float)num23 * this.scale), false, false, 1); vector.X *= 0.97f; if ((double)vector.X > -0.01 && (double)vector.X < 0.01) { vector.X = 0f; } if (this.timeLeft > 0) { this.timeLeft--; } else { this.alpha++; } this.velocity.X = vector.X; } else { this.velocity.Y = this.velocity.Y + 0.05235988f; Vector2 vector2 = new Vector2(Vector2.UnitY.RotatedBy((double)this.velocity.Y, default(Vector2)).X * 2f, Math.Abs(Vector2.UnitY.RotatedBy((double)this.velocity.Y, default(Vector2)).Y) * 3f); vector2 *= 2f; int num24 = 32; if (Main.goreLoaded[this.type]) { num24 = Main.goreTexture[this.type].Width; if (Main.goreTexture[this.type].Height < num24) { num24 = Main.goreTexture[this.type].Height; } } Vector2 value4 = vector2; vector2 = Collision.TileCollision(this.position, vector2, (int)((float)num24 * this.scale), (int)((float)num24 * this.scale), false, false, 1); if (vector2 != value4) { this.velocity.Y = -1f; } this.position += vector2; this.rotation = vector2.ToRotation() + 3.14159274f; if (this.timeLeft > 0) { this.timeLeft--; } else { this.alpha++; } } } else { this.position += this.velocity; } if (this.alpha >= 255) { this.active = false; } if (this.light > 0f) { float num25 = this.light * this.scale; float num26 = this.light * this.scale; float num27 = this.light * this.scale; if (this.type == 16) { num27 *= 0.3f; num26 *= 0.8f; } else if (this.type == 17) { num26 *= 0.6f; num25 *= 0.3f; } if (Main.goreLoaded[this.type]) { Lighting.AddLight((int)((this.position.X + (float)Main.goreTexture[this.type].Width * this.scale / 2f) / 16f), (int)((this.position.Y + (float)Main.goreTexture[this.type].Height * this.scale / 2f) / 16f), num25, num26, num27); return; } Lighting.AddLight((int)((this.position.X + 32f * this.scale / 2f) / 16f), (int)((this.position.Y + 32f * this.scale / 2f) / 16f), num25, num26, num27); } } }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Player player = Main.player[projectile.owner]; Texture2D texture = Main.projectileTexture[projectile.type]; int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y2 = height * projectile.frame; if (player.direction == 1) { SpriteEffects effects1 = SpriteEffects.None; Vector2 position = (projectile.position + (0.5f * direction) + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition).Floor(); Main.spriteBatch.Draw(texture, position, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y2, texture.Width, height)), lightColor, direction.ToRotation(), new Vector2((float)texture.Width / 8f, (float)height * .75f), projectile.scale, effects1, 0.0f); } else { SpriteEffects effects1 = SpriteEffects.FlipHorizontally; Vector2 position = (projectile.position - (0.5f * direction) + new Vector2((float)projectile.width, (float)projectile.height) / 2f + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition).Floor(); Main.spriteBatch.Draw(texture, position, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(0, y2, texture.Width, height)), lightColor, direction.ToRotation() - 3.14f, new Vector2((float)texture.Width / 8f, (float)height * .75f), projectile.scale, effects1, 0.0f); } return(false); }