public override void AI() { Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.675f, 2.50f); }
public override void AI() { Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.08f, 0.04f, 0.2f); npc.spriteDirection = npc.direction; }
public override void AI() { Lighting.AddLight(projectile.Center, .7f, 0f, 0f); ActiveSound activeSound = Main.GetActiveSound(SlotId.FromFloat(projectile.localAI[0])); if (activeSound != null) { if (activeSound.Volume == 0f) { activeSound.Stop(); projectile.localAI[0] = SlotId.Invalid.ToFloat(); } activeSound.Volume = Math.Max(0f, activeSound.Volume - 0.05f); } else { projectile.localAI[0] = SlotId.Invalid.ToFloat(); } if (projectile.ai[1] == 1f) { if (projectile.alpha < 255) { projectile.alpha += 51; } if (projectile.alpha >= 255) { projectile.alpha = 255; projectile.Kill(); return; } } else { if (projectile.alpha > 0) { projectile.alpha -= 50; } if (projectile.alpha < 0) { projectile.alpha = 0; } } float num726 = 30f; float num727 = num726 * 4f; projectile.ai[0] += 1f; if (projectile.ai[0] > num727) { projectile.ai[0] = 0f; } Vector2 vector62 = -Vector2.UnitY.RotatedBy(6.28318548f * projectile.ai[0] / num726, default); float val = 0.75f + vector62.Y * 0.25f; float val2 = 0.8f - vector62.Y * 0.2f; float num728 = Math.Max(val, val2); projectile.position += new Vector2(projectile.width, projectile.height) / 2f; projectile.width = (projectile.height = (int)(80f * num728)); projectile.position -= new Vector2(projectile.width, projectile.height) / 2f; projectile.frameCounter++; if (projectile.frameCounter >= 3) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame >= 4) { projectile.frame = 0; } } for (int num729 = 0; num729 < 1; num729++) { float num730 = 55f * num728; float num731 = 11f * num728; float num732 = 0.5f; int num733 = Dust.NewDust(projectile.position, projectile.width, projectile.height, ModContent.DustType <Dusts.VoidDust>(), 0f, 0f, 100, default, 0.5f);
public override bool PreDrawExtras(SpriteBatch spriteBatch) { //Create some light based on the color of the line; this could also be in the AI function Lighting.AddLight(projectile.Center, fishingLineColor.R / 255, fishingLineColor.G / 255, fishingLineColor.B / 255); //Change these two values in order to change the origin of where the line is being drawn int xPositionAdditive = 45; float yPositionAdditive = 35f; Player player = Main.player[projectile.owner]; if (!projectile.bobber || player.inventory[player.selectedItem].holdStyle <= 0) { return(false); } Vector2 lineOrigin = player.MountedCenter; lineOrigin.Y += player.gfxOffY; int type = player.inventory[player.selectedItem].type; //This variable is used to account for Gravitation Potions float gravity = player.gravDir; if (type == ItemType <ExampleFishingRod>()) { lineOrigin.X += xPositionAdditive * player.direction; if (player.direction < 0) { lineOrigin.X -= 13f; } lineOrigin.Y -= yPositionAdditive * gravity; } if (gravity == -1f) { lineOrigin.Y -= 12f; } // RotatedRelativePoint adjusts lineOrigin to account for player rotation. lineOrigin = player.RotatedRelativePoint(lineOrigin + new Vector2(8f), true) - new Vector2(8f); Vector2 playerToProjectile = projectile.Center - lineOrigin; bool canDraw = true; if (playerToProjectile.X == 0f && playerToProjectile.Y == 0f) { return(false); } float playerToProjectileMagnitude = playerToProjectile.Length(); playerToProjectileMagnitude = 12f / playerToProjectileMagnitude; playerToProjectile *= playerToProjectileMagnitude; lineOrigin -= playerToProjectile; playerToProjectile = projectile.Center - lineOrigin; // This math draws the line, while allowing the line to sag. while (canDraw) { float height = 12f; float positionMagnitude = playerToProjectile.Length(); if (float.IsNaN(positionMagnitude) || float.IsNaN(positionMagnitude)) { break; } if (positionMagnitude < 20f) { height = positionMagnitude - 8f; canDraw = false; } playerToProjectile *= 12f / positionMagnitude; lineOrigin += playerToProjectile; playerToProjectile.X = projectile.position.X + projectile.width * 0.5f - lineOrigin.X; playerToProjectile.Y = projectile.position.Y + projectile.height * 0.1f - lineOrigin.Y; if (positionMagnitude > 12f) { float positionInverseMultiplier = 0.3f; float absVelocitySum = Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y); if (absVelocitySum > 16f) { absVelocitySum = 16f; } absVelocitySum = 1f - absVelocitySum / 16f; positionInverseMultiplier *= absVelocitySum; absVelocitySum = positionMagnitude / 80f; if (absVelocitySum > 1f) { absVelocitySum = 1f; } positionInverseMultiplier *= absVelocitySum; if (positionInverseMultiplier < 0f) { positionInverseMultiplier = 0f; } absVelocitySum = 1f - projectile.localAI[0] / 100f; positionInverseMultiplier *= absVelocitySum; if (playerToProjectile.Y > 0f) { playerToProjectile.Y *= 1f + positionInverseMultiplier; playerToProjectile.X *= 1f - positionInverseMultiplier; } else { absVelocitySum = Math.Abs(projectile.velocity.X) / 3f; if (absVelocitySum > 1f) { absVelocitySum = 1f; } absVelocitySum -= 0.5f; positionInverseMultiplier *= absVelocitySum; if (positionInverseMultiplier > 0f) { positionInverseMultiplier *= 2f; } playerToProjectile.Y *= 1f + positionInverseMultiplier; playerToProjectile.X *= 1f - positionInverseMultiplier; } } //This color decides the color of the fishing line. The color is randomized as decided in the AI. Color lineColor = Lighting.GetColor((int)lineOrigin.X / 16, (int)(lineOrigin.Y / 16f), fishingLineColor); float rotation = playerToProjectile.ToRotation() - MathHelper.PiOver2; Main.spriteBatch.Draw(Main.fishingLineTexture, new Vector2(lineOrigin.X - Main.screenPosition.X + Main.fishingLineTexture.Width * 0.5f, lineOrigin.Y - Main.screenPosition.Y + Main.fishingLineTexture.Height * 0.5f), new Rectangle(0, 0, Main.fishingLineTexture.Width, (int)height), lineColor, rotation, new Vector2(Main.fishingLineTexture.Width * 0.5f, 0f), 1f, SpriteEffects.None, 0f); } return(false); }
public override void HoldItem(Player player) { Lighting.AddLight(player.Center, 1f, 0f, 0f); }
public override void AI() { Lighting.AddLight(npc.Center, Color.OrangeRed.ToVector3()); Player player = Main.player[npc.target]; npc.TargetClosest(true); npc.spriteDirection = -npc.direction; npc.ai[0] = ((npc.Distance(player.Center) < 800 || npc.ai[2] > rechargetime) && Collision.CanHit(npc.position, npc.width, npc.height, player.position, 0, 0) && player.active && !player.dead) ? 1 : 0; if (npc.ai[0] == 0) { IdleMovement(); npc.ai[1] = 0; //dash timer npc.ai[2] = 0; //targetting timer npc.ai[3] = 0; } else //set its target position as the player's center when it starts its enrage, then dash to it once per frame cycle. If it's close enough to the target position, explode and retarget { if (npc.ai[2] <= rechargetime) { IdleMovement(); targetpos = player.Center; npc.ai[2]++; } else { if (npc.ai[3] == 0) { SpiritMod.primitives.CreateTrail(new PrimFireTrail(npc, new Color(255, 170, 0), 26)); npc.ai[3] = 1; } npc.spriteDirection = -Math.Sign(npc.velocity.X); if (Main.rand.Next(4) == 0) { Gore.NewGorePerfect(npc.Center + Main.rand.NextVector2Circular(10, 10), npc.velocity.RotatedByRandom(MathHelper.Pi / 8) / 2, mod.GetGoreSlot("Gores/FireTrail"), Main.rand.NextFloat(0.7f, 1.2f)); } if (Main.expertMode) { targetpos = Vector2.Lerp(targetpos, player.Center, 0.03f); } if (npc.ai[1] == 0) { Main.PlaySound(mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/skullscrem").WithPitchVariance(0.2f), npc.Center); npc.velocity = npc.DirectionTo(targetpos) * 14; npc.ai[1]++; } if (Main.expertMode) { npc.velocity = Vector2.Lerp(npc.velocity, npc.DirectionTo(targetpos) * 14, 0.2f); } if (frame > 10) { npc.velocity = Vector2.Lerp(npc.velocity, Vector2.Zero, 0.05f); } if (npc.Distance(targetpos) < 20) { Main.PlaySound(SoundID.Item14, npc.Center); int damage = (Main.expertMode) ? npc.damage / 4 : npc.damage / 2; for (int i = 0; i < 6; i++) { Gore.NewGore(npc.Center + Main.rand.NextVector2Square(-20, 20), Main.rand.NextVector2Circular(3, 3), 11); } Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("WrathBoom"), damage, 1, Main.myPlayer); npc.velocity = Vector2.Zero; npc.ai[2] = 0; npc.ai[3] = 0; } UpdateFrame(20, 6, 16); } } CheckPlatform(); }
public override void AI() { if (npc.ai[0] < 0f || npc.ai[0] >= 200f) { npc.active = false; npc.netUpdate = true; return; } NPC plantera = Main.npc[(int)npc.ai[0]]; if (!plantera.active || plantera.type != NPCID.Plantera) { npc.active = false; npc.netUpdate = true; return; } if (npc.HasPlayerTarget && Main.player[npc.target].active) { npc.ai[2]++; if (npc.ai[2] > 240f) //projectile timer { npc.ai[2] = 0; npc.netUpdate = true; Main.PlaySound(6, (int)npc.position.X, (int)npc.position.Y); if (Main.netMode != -1) { Vector2 distance = Main.player[npc.target].Center - npc.Center + Main.player[npc.target].velocity * 30f; distance.Normalize(); distance *= 16f; int damage = 24; if (!Main.player[npc.target].ZoneJungle) { damage = damage * 2; } else if (Main.expertMode) { damage = damage * 9 / 10; } damage = (int)(damage * (1 + FargoWorld.PlanteraCount * .0125)); Projectile.NewProjectile(npc.Center, distance, mod.ProjectileType("CrystalLeafShot"), damage, 0f, Main.myPlayer); } for (int index1 = 0; index1 < 30; ++index1) { int index2 = Dust.NewDust(npc.position, npc.width, npc.height, 157, 0f, 0f, 0, new Color(), 2f); Main.dust[index2].noGravity = true; Main.dust[index2].velocity *= 5f; } } } else { npc.TargetClosest(false); } Lighting.AddLight(npc.Center, 0.1f, 0.4f, 0.2f); npc.scale = (Main.mouseTextColor / 200f - 0.35f) * 0.2f + 0.95f; npc.life = npc.lifeMax; npc.position = plantera.Center + new Vector2(npc.ai[1], 0f).RotatedBy(npc.ai[3]); npc.position.X -= npc.width / 2; npc.position.Y -= npc.height / 2; float rotation = 0.03f; npc.ai[3] += rotation; if (npc.ai[3] > (float)Math.PI) { npc.ai[3] -= 2f * (float)Math.PI; npc.netUpdate = true; } npc.rotation = npc.ai[3] + (float)Math.PI / 2f; }
public override void AI() { projectile.frameCounter = projectile.frameCounter + 1; Lighting.AddLight(projectile.Center, 0.3f, 0.45f, 0.5f); colorlerp += 0.05f; if (!playedsound) { Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 122, 0.5f, -0.5f); playedsound = true; startSpeed = projectile.velocity.Length(); } 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(); return; } } if (Main.rand.Next(projectile.extraUpdates) != 0) { return; } for (int index1 = 0; index1 < 2; ++index1) { 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); int index2 = Dust.NewDust(projectile.Center, 0, 0, 226, vector2.X, vector2.Y, 0, new Color(), 1f); Main.dust[index2].noGravity = true; Main.dust[index2].scale = 1.2f; } 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); Dust dust = Main.dust[index3]; dust.velocity = dust.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--; } 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] > 40.0) { flag = true; } if ((double)rotationVector2.X * (double)(projectile.extraUpdates + 1) * 2.0 * (double)num1 + (double)projectile.localAI[0] < -40.0) { flag = true; } if (flag) { num3 = num2; num2 = num3 + 1; } else { goto label_3460; } }while (num3 < 100); projectile.velocity = Vector2.Zero; projectile.localAI[1] = 1f; goto label_3461; label_3460: spinningpoint = rotationVector2; label_3461: if (projectile.velocity == Vector2.Zero || projectile.velocity.Length() < 4f) { projectile.velocity = Vector2.UnitX.RotatedBy(projectile.ai[0]).RotatedByRandom(Math.PI / 4) * startSpeed; projectile.ai[1] = Main.rand.Next(100); 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; } /*for (int index1 = 1; index1 < projectile.oldPos.Length; index1++) * { * const int max = 5; * Vector2 offset = projectile.oldPos[index1 - 1] - projectile.oldPos[index1]; * offset /= max; * for (int i = 0; i < 5; i++) * { * Vector2 position = projectile.oldPos[index1] + offset * i; * int index2 = Dust.NewDust(position, projectile.width, projectile.height, 160, 0.0f, 0.0f, 0, new Color(), 1f); * Main.dust[index2].scale = Main.rand.Next(70, 110) * 0.013f; * Main.dust[index2].velocity *= 0.2f; * } * }*/ }
public override void AI() { Player player = Main.player[projectile.owner]; if (player.active && player.GetModPlayer <MyPlayer>().MinionCurrentlyActive == false) { player.GetModPlayer <MyPlayer>().MinionCurrentlyActive = true; projectile.timeLeft = 5; } else { player.GetModPlayer <MyPlayer>().MinionCurrentlyActive = false; } if (!player.GetModPlayer <MyPlayer>().StandControlActive) { Lighting.AddLight((int)(projectile.Center.X / 16f), (int)(projectile.Center.Y / 16f), 0.6f, 0.9f, 0.3f); Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 35, projectile.velocity.X * -0.5f, projectile.velocity.Y * -0.5f); Vector2 vector131 = player.Center; if (!front) { vector131.X -= (float)((15 + player.width / 2) * player.direction); } if (front) { vector131.X -= (float)((15 + player.width / 2) * (player.direction * -1)); } vector131.Y -= 15f; projectile.Center = Vector2.Lerp(projectile.Center, vector131, 0.2f); projectile.velocity *= 0.8f; projectile.direction = (projectile.spriteDirection = player.direction); Vector2 targetPos = projectile.position; float targetDist = 350f; bool target = false; projectile.tileCollide = true; for (int k = 0; k < 200; k++) { NPC npc = Main.npc[k]; normalFrames = true; if (npc.CanBeChasedBy(this, false)) { float distance = Vector2.Distance(npc.Center, projectile.Center); if ((distance < targetDist || !target) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { targetDist = distance; targetPos = npc.Center; target = true; } } } SelectFrame(); if (projectile.ai[1] > 0f) { projectile.ai[1] += 1f; if (Main.rand.Next(3) == 0) { projectile.ai[1] += 1f; } } if (projectile.ai[1] > shootCool) { projectile.ai[1] = 0f; projectile.netUpdate = true; } if (projectile.ai[0] == 0f) { if (target) { Main.PlaySound(SoundID.Item21, projectile.position); attackFrames = true; front = true; normalFrames = false; if ((targetPos - projectile.Center).X > 0f) { projectile.spriteDirection = (projectile.direction = 1); } else if ((targetPos - projectile.Center).X < 0f) { projectile.spriteDirection = (projectile.direction = -1); } if (projectile.ai[1] == 0f) { projectile.ai[1] = 1f; if (Main.myPlayer == projectile.owner) { Vector2 shootVel = targetPos - projectile.Center; if (shootVel == Vector2.Zero) { shootVel = new Vector2(0f, 1f); } shootVel.Normalize(); shootVel *= shootSpeed; float numberProjectiles = 3 + Main.rand.Next(1); float rotation = MathHelper.ToRadians(15); for (int i = 0; i < numberProjectiles; i++) { Vector2 perturbedSpeed = new Vector2(shootVel.X, shootVel.Y).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, shoot, 52, 2f, player.whoAmI); Main.projectile[proj].netUpdate = true; } projectile.netUpdate = true; } } } else { front = false; attackFrames = false; } } } if (player.GetModPlayer <MyPlayer>().StandControlActive&& MyPlayer.StandControlBinds && !MyPlayer.StandControlMouse) { SelectFrame(); normalFrames = true; attackFrames = false; if (JoJoStands.StandControlUp.Current) { projectile.velocity.Y -= 0.3f; } if (JoJoStands.StandControlDown.Current) { projectile.velocity.Y += 0.3f; } if (JoJoStands.StandControlLeft.Current) { projectile.velocity.X -= 0.3f; projectile.spriteDirection = -1; projectile.direction = -1; } if (JoJoStands.StandControlRight.Current) { projectile.velocity.X += 0.3f; projectile.spriteDirection = 1; projectile.direction = 1; } if (JoJoStands.StandControlAttack.Current) { attackFrames = true; normalFrames = false; if (shootcount <= 0) { Main.PlaySound(SoundID.Item21, projectile.position); shootcount += 24; Vector2 shootVel = Main.MouseWorld - projectile.Center; if (shootVel == Vector2.Zero) { shootVel = new Vector2(0f, 1f); } shootVel.Normalize(); shootVel *= shootSpeed; float numberProjectiles = 3 + Main.rand.Next(1); float rotation = MathHelper.ToRadians(15); for (int i = 0; i < numberProjectiles; i++) { Vector2 perturbedSpeed = new Vector2(shootVel.X, shootVel.Y).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, shoot, 52, 2f, player.whoAmI); Main.projectile[proj].netUpdate = true; } projectile.netUpdate = true; } } if (!JoJoStands.StandControlUp.Current && !JoJoStands.StandControlDown.Current && !JoJoStands.StandControlLeft.Current && !JoJoStands.StandControlRight.Current) { projectile.velocity.X *= 0.5f; //so that it stops floating away at 0.3 velocity... projectile.velocity.Y *= 0.5f; } projectile.netUpdate = true; } if (player.GetModPlayer <MyPlayer>().StandControlActive&& MyPlayer.StandControlMouse && !MyPlayer.StandControlBinds) { SelectFrame(); if (Main.mouseLeft) { if (projectile.position.X <= Main.MouseWorld.X) { projectile.velocity.X = 5f; } if (projectile.position.X >= Main.MouseWorld.X) { projectile.velocity.X = -5f; } if (projectile.position.Y >= Main.MouseWorld.Y) { projectile.velocity.Y = -5f; } if (projectile.position.Y <= Main.MouseWorld.Y) { projectile.velocity.Y = 5f; } if (projectile.position.X == (Main.MouseWorld.X / 16f)) { projectile.velocity.X = 0f; } if (projectile.position.Y == (Main.MouseWorld.X / 16f)) { projectile.velocity.Y = 0f; } } else { projectile.velocity = Vector2.Zero; } if (Main.MouseWorld.X >= projectile.position.X && projectile.position.X != (Main.MouseWorld.X / 16f)) { projectile.spriteDirection = 1; projectile.direction = 1; } if (Main.MouseWorld.X <= projectile.position.X && projectile.position.X != (Main.MouseWorld.X / 16f)) { projectile.spriteDirection = -1; projectile.direction = -1; } if (Main.mouseRight) { SelectFrame(); attackFrames = true; normalFrames = true; if (shootcount <= 0) { Main.PlaySound(SoundID.Item21, projectile.position); shootcount += 24; Vector2 shootVel = Main.MouseWorld - projectile.Center; if (shootVel == Vector2.Zero) { shootVel = new Vector2(0f, 1f); } shootVel.Normalize(); shootVel *= shootSpeed; float numberProjectiles = 3 + Main.rand.Next(1); float rotation = MathHelper.ToRadians(15); for (int i = 0; i < numberProjectiles; i++) { Vector2 perturbedSpeed = new Vector2(shootVel.X, shootVel.Y).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, shoot, 52, 2f, player.whoAmI); Main.projectile[proj].netUpdate = true; } } } else { attackFrames = false; normalFrames = true; } projectile.netUpdate = true; } if (player.GetModPlayer <MyPlayer>().StandControlActive&& (MyPlayer.StandControlBinds || MyPlayer.StandControlMouse)) //when using stand control, to limit how far the stand can go { shootcount--; Vector2 direction = player.Center - projectile.Center; float distanceTo = direction.Length(); if (distanceTo > 250f) //if the projectiles position are greater than distanceTo, make it stay on distanceTo { if (projectile.position.X <= player.position.X) { projectile.position = new Vector2(projectile.position.X + 1, projectile.position.Y); projectile.velocity = Vector2.Zero; } if (projectile.position.X >= player.position.X) { projectile.position = new Vector2(projectile.position.X - 1, projectile.position.Y); projectile.velocity = Vector2.Zero; } if (projectile.position.Y >= player.position.Y) { projectile.position = new Vector2(projectile.position.X, projectile.position.Y - 1); projectile.velocity = Vector2.Zero; } if (projectile.position.Y <= player.position.Y) { projectile.position = new Vector2(projectile.position.X, projectile.position.Y + 1); projectile.velocity = Vector2.Zero; } centerTimer++; } else { centerTimer = 0; } } if (shootcount <= 0) { shootcount = 0; } if (centerTimer >= 300) { player.GetModPlayer <MyPlayer>().StandControlActive = false; MyPlayer.StandControlBinds = false; MyPlayer.StandControlMouse = false; projectile.position = player.position; centerTimer = 0; } }
public override void PostUpdate() { Lighting.AddLight((int)(item.position.X / 16f), (int)(item.position.Y / 16f), 0, 0, 0.25f); }
public override void AI() { Player player = Main.player[projectile.owner]; #region Active check // This is the "active check", makes sure the minion is alive while the player is alive, and despawns if not if (player.dead || !player.active) { player.ClearBuff(BuffType <Sifter2>()); } if (player.HasBuff(BuffType <Sifter2>())) { projectile.timeLeft = 2; } #endregion Active check #region General behavior Vector2 idlePosition = player.Center; idlePosition.Y -= 48f; // Go up 48 coordinates (three tiles from the center of the player) // If your minion doesn't aimlessly move around when it's idle, you need to "put" it into the line of other summoned minions // The index is projectile.minionPos float minionPositionOffsetX = (10 + projectile.minionPos * 40) * -player.direction; idlePosition.X += minionPositionOffsetX; // Go behind the player // All of this code below this line is adapted from Spazmamini code (ID 388, aiStyle 66) // Teleport to player if distance is too big Vector2 vectorToIdlePosition = idlePosition - projectile.Center; float distanceToIdlePosition = vectorToIdlePosition.Length(); if (Main.myPlayer == player.whoAmI && distanceToIdlePosition > 2000f) { // Whenever you deal with non-regular events that change the behavior or position drastically, make sure to only run the code on the owner of the projectile, // and then set netUpdate to true projectile.position = idlePosition; projectile.velocity *= 0.1f; projectile.netUpdate = true; } // If your minion is flying, you want to do this independently of any conditions float overlapVelocity = 0.04f; for (int i = 0; i < Main.maxProjectiles; i++) { // Fix overlap with other minions Projectile other = Main.projectile[i]; if (i != projectile.whoAmI && other.active && other.owner == projectile.owner && Math.Abs(projectile.position.X - other.position.X) + Math.Abs(projectile.position.Y - other.position.Y) < projectile.width) { if (projectile.position.X < other.position.X) { projectile.velocity.X -= overlapVelocity; } else { projectile.velocity.X += overlapVelocity; } if (projectile.position.Y < other.position.Y) { projectile.velocity.Y -= overlapVelocity; } else { projectile.velocity.Y += overlapVelocity; } } } #endregion General behavior #region Find target // Starting search distance float distanceFromTarget = 700f; Vector2 targetCenter = projectile.position; bool foundTarget = false; // This code is required if your minion weapon has the targeting feature if (player.HasMinionAttackTargetNPC) { NPC npc = Main.npc[player.MinionAttackTargetNPC]; float between = Vector2.Distance(npc.Center, projectile.Center); // Reasonable distance away so it doesn't target across multiple screens if (between < 2000f) { distanceFromTarget = between; targetCenter = npc.Center; foundTarget = true; } } if (!foundTarget) { // This code is required either way, used for finding a target for (int i = 0; i < Main.maxNPCs; i++) { NPC npc = Main.npc[i]; if (npc.CanBeChasedBy()) { float between = Vector2.Distance(npc.Center, projectile.Center); bool closest = Vector2.Distance(projectile.Center, targetCenter) > between; bool inRange = between < distanceFromTarget; bool lineOfSight = Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height); // Additional check for this specific minion behavior, otherwise it will stop attacking once it dashed through an enemy while flying though tiles afterwards // The number depends on various parameters seen in the movement code below. Test different ones out until it works alright bool closeThroughWall = between < 100f; if (((closest && inRange) || !foundTarget) && (lineOfSight || closeThroughWall)) { distanceFromTarget = between; targetCenter = npc.Center; foundTarget = true; } } } } // friendly needs to be set to true so the minion can deal contact damage // friendly needs to be set to false so it doesn't damage things like target dummies while idling // Both things depend on if it has a target or not, so it's just one assignment here // You don't need this assignment if your minion is shooting things instead of dealing contact damage projectile.friendly = foundTarget; #endregion Find target #region Movement // Default movement parameters (here for attacking) float speed = 10f; float inertia = 15f; if (foundTarget) { // Minion has a target: attack (here, fly towards the enemy) if (distanceFromTarget > 40f) { // The immediate range around the target (so it doesn't latch onto it when close) Vector2 direction = targetCenter - projectile.Center; direction.Normalize(); direction *= speed; projectile.velocity = (projectile.velocity * (inertia - 1) + direction) / inertia; } } else { // Minion doesn't have a target: return to player and idle if (distanceToIdlePosition > 600f) { // Speed up the minion if it's away from the player speed = 14f; inertia = 60f; } else { // Slow down the minion if closer to the player speed = 8f; inertia = 80f; } if (distanceToIdlePosition > 20f) { // The immediate range around the player (when it passively floats about) // This is a simple movement formula using the two parameters and its desired direction to create a "homing" movement vectorToIdlePosition.Normalize(); vectorToIdlePosition *= speed; projectile.velocity = (projectile.velocity * (inertia - 1) + vectorToIdlePosition) / inertia; } else if (projectile.velocity == Vector2.Zero) { // If there is a case where it's not moving at all, give it a little "poke" projectile.velocity.X = -0.15f; projectile.velocity.Y = -0.05f; } } #endregion Movement #region Animation and visuals // So it will lean slightly towards the direction it's moving projectile.rotation = projectile.velocity.X * 0.05f; // This is a simple "loop through all frames from top to bottom" animation int frameSpeed = 5; projectile.frameCounter++; if (projectile.frameCounter >= frameSpeed) { projectile.frameCounter = 0; projectile.frame++; if (projectile.frame >= Main.projFrames[projectile.type]) { projectile.frame = 0; } } // Some visuals here Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 0.78f); #endregion Animation and visuals }
/*public override void AutoloadHead(ref string headTexture, ref string bossHeadTexture) * { * bossHeadTexture = CalamityMod.stormWeaverHead; * }*/ public override void AI() { Player player = Main.player[npc.target]; bool expertMode = Main.expertMode; Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0f, 0.075f, 0.25f); if ((npc.life <= npc.lifeMax * 0.5f)) { if (npc.localAI[0] == 0f) { npc.localAI[0] = 1f; for (int num723 = 0; num723 < 5; num723++) { NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("CogTrapperHead"), npc.whoAmI, 0f, 0f, 0f, 0f, 255); } } } if (npc.ai[3] > 0f) { npc.realLife = (int)npc.ai[3]; } if (npc.target < 0 || npc.target == 255 || player.dead) { npc.TargetClosest(true); } npc.velocity.Length(); if (npc.alpha != 0) { for (int num934 = 0; num934 < 2; num934++) { int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 226, 0f, 0f, 100, default(Color), 2f); Main.dust[num935].noGravity = true; Main.dust[num935].noLight = true; } } npc.alpha -= 12; if (npc.alpha < 0) { npc.alpha = 0; } if (Main.netMode != 1) { if (!tail && npc.ai[0] == 0f) { int Previous = npc.whoAmI; for (int num36 = 0; num36 < maxLength; num36++) { int lol = 0; if (num36 >= 0 && num36 < minLength) { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), mod.NPCType("SteamRaiderBody"), npc.whoAmI); } else { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), mod.NPCType("SteamRaiderTail"), npc.whoAmI); } Main.npc[lol].realLife = npc.whoAmI; Main.npc[lol].ai[2] = (float)npc.whoAmI; Main.npc[lol].ai[1] = (float)Previous; Main.npc[Previous].ai[0] = (float)lol; npc.netUpdate = true; Previous = lol; } tail = true; } if (!npc.active && Main.netMode == 2) { NetMessage.SendData(28, -1, -1, "", npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); } } int num180 = (int)(npc.position.X / 16f) - 1; int num181 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; int num182 = (int)(npc.position.Y / 16f) - 1; int num183 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; if (num180 < 0) { num180 = 0; } if (num181 > Main.maxTilesX) { num181 = Main.maxTilesX; } if (num182 < 0) { num182 = 0; } if (num183 > Main.maxTilesY) { num183 = Main.maxTilesY; } bool flag94 = flies; npc.localAI[1] = 0f; if (directional) { if (npc.velocity.X < 0f) { npc.spriteDirection = 1; } else if (npc.velocity.X > 0f) { npc.spriteDirection = -1; } } if (player.dead) { npc.TargetClosest(false); flag94 = false; npc.velocity.Y = npc.velocity.Y + 10f; if ((double)npc.position.Y > Main.worldSurface * 16.0) { npc.velocity.Y = npc.velocity.Y + 10f; } if ((double)npc.position.Y > Main.rockLayer * 16.0) { for (int num957 = 0; num957 < 200; num957++) { if (Main.npc[num957].aiStyle == npc.aiStyle) { Main.npc[num957].active = false; } } } } Vector2 value = npc.Center + (npc.rotation - 1.57079637f).ToRotationVector2() * 8f; Vector2 value2 = npc.rotation.ToRotationVector2() * 16f; Dust dust = Main.dust[Dust.NewDust(value + value2, 0, 0, 226, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 0.5f + Main.rand.NextFloat() * 1.5f)]; dust.noGravity = true; dust.noLight = true; dust.position -= new Vector2(2f); //4 dust.fadeIn = 1f; dust.velocity = Vector2.Zero; dust = Main.dust[Dust.NewDust(value - value2, 0, 0, 226, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 0.5f + Main.rand.NextFloat() * 1.5f)]; dust.noGravity = true; dust.noLight = true; dust.position -= new Vector2(2f); //4 dust.fadeIn = 1f; dust.velocity = Vector2.Zero; float num188 = speed; float num189 = turnSpeed; Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num191 = player.position.X + (float)(player.width / 2); float num192 = player.position.Y + (float)(player.height / 2); int num42 = -1; int num43 = (int)(player.Center.X / 16f); int num44 = (int)(player.Center.Y / 16f); for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) { for (int num46 = num44; num46 <= num44 + 15; num46++) { if (WorldGen.SolidTile2(num45, num46)) { num42 = num46; break; } } if (num42 > 0) { break; } } if (num42 > 0) { npc.defense = 15; num42 *= 16; float num47 = (float)(num42 - 400); //was 800 if (player.position.Y > num47) { num192 = num47; if (Math.Abs(npc.Center.X - player.Center.X) < 250f) //was 500 { if (npc.velocity.X > 0f) { num191 = player.Center.X + 300f; //was 600 } else { num191 = player.Center.X - 300f; //was 600 } } } } else { npc.defense = 0; num188 = expertMode ? 12.5f : 10f; //added 2.5 num189 = expertMode ? 0.25f : 0.2f; //added 0.05 } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); if (num50 > 0f) { if (num50 > num48) { npc.velocity.Normalize(); npc.velocity *= num48; } else if (num50 < num49) { npc.velocity.Normalize(); npc.velocity *= num49; } } if (num42 > 0) { for (int num51 = 0; num51 < 200; num51++) { if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) { Vector2 vector3 = Main.npc[num51].Center - npc.Center; if (vector3.Length() < 400f) { vector3.Normalize(); vector3 *= 1000f; num191 -= vector3.X; num192 -= vector3.Y; } } } } else { for (int num52 = 0; num52 < 200; num52++) { if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) { Vector2 vector4 = Main.npc[num52].Center - npc.Center; if (vector4.Length() < 60f) { vector4.Normalize(); vector4 *= 200f; num191 -= vector4.X; num192 -= vector4.Y; } } } } num191 = (float)((int)(num191 / 16f) * 16); num192 = (float)((int)(num192 / 16f) * 16); vector18.X = (float)((int)(vector18.X / 16f) * 16); vector18.Y = (float)((int)(vector18.Y / 16f) * 16); num191 -= vector18.X; num192 -= vector18.Y; float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) { try { vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); int num194 = npc.width; num193 = (num193 - (float)num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; npc.position.X = npc.position.X + num191; npc.position.Y = npc.position.Y + num192; if (directional) { if (num191 < 0f) { npc.spriteDirection = 1; } if (num191 > 0f) { npc.spriteDirection = -1; } } } else { num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); float num196 = System.Math.Abs(num191); float num197 = System.Math.Abs(num192); float num198 = num188 / num193; num191 *= num198; num192 *= num198; bool flag21 = false; if (!flag21) { if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) { if (npc.velocity.X < num191) { npc.velocity.X = npc.velocity.X + num189; } else { if (npc.velocity.X > num191) { npc.velocity.X = npc.velocity.X - num189; } } if (npc.velocity.Y < num192) { npc.velocity.Y = npc.velocity.Y + num189; } else { if (npc.velocity.Y > num192) { npc.velocity.Y = npc.velocity.Y - num189; } } if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) { if (npc.velocity.Y > 0f) { npc.velocity.Y = npc.velocity.Y + num189 * 2f; } else { npc.velocity.Y = npc.velocity.Y - num189 * 2f; } } if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) { if (npc.velocity.X > 0f) { npc.velocity.X = npc.velocity.X + num189 * 2f; //changed from 2 } else { npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 } } } else { if (num196 > num197) { if (npc.velocity.X < num191) { npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 } else if (npc.velocity.X > num191) { npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 } if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) { if (npc.velocity.Y > 0f) { npc.velocity.Y = npc.velocity.Y + num189; } else { npc.velocity.Y = npc.velocity.Y - num189; } } } else { if (npc.velocity.Y < num192) { npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; } else if (npc.velocity.Y > num192) { npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; } if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) { if (npc.velocity.X > 0f) { npc.velocity.X = npc.velocity.X + num189; } else { npc.velocity.X = npc.velocity.X - num189; } } } } } } npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; }
public override void DrawEffects(NPC npc, ref Color drawColor) { if (LeadPoison) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.Lead, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 1f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.Next(4) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } if (OriPoison) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.PinkFlame, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 1f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.Next(4) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } if (HellFire) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.SolarFlare, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].shader = GameShaders.Armor.GetSecondaryShader(56, Main.LocalPlayer); Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.Next(4) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } if (SBleed) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.Blood, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].shader = GameShaders.Armor.GetSecondaryShader(56, Main.LocalPlayer); Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.Next(4) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } /*if (Infested) * { * if (Main.rand.Next(4) < 3) * { * int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, 44, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, Color.LimeGreen, InfestedDust); * Main.dust[dust].noGravity = true; * Main.dust[dust].velocity *= 1.8f; * Dust expr_1CCF_cp_0 = Main.dust[dust]; * expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; * if (Main.rand.Next(4) == 0) * { * Main.dust[dust].noGravity = false; * Main.dust[dust].scale *= 0.5f; * } * } * * Lighting.AddLight((int)(npc.position.X / 16f), (int)(npc.position.Y / 16f + 1f), 1f, 0.3f, 0.1f); * }*/ if (Suffocation) { drawColor = Colors.RarityPurple; } if (Villain) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.AncientLight, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.Next(4) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } Lighting.AddLight((int)(npc.position.X / 16f), (int)(npc.position.Y / 16f + 1f), 1f, 0.3f, 0.1f); } if (Electrified) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, 229, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; if (Main.rand.Next(3) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.3f, 0.8f, 1.1f); } if (CurseoftheMoon) { int d = Dust.NewDust(npc.Center, 0, 0, 229, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 3f; Main.dust[d].scale += 0.5f; if (Main.rand.Next(4) < 3) { d = Dust.NewDust(npc.position, npc.width, npc.height, 229, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity.Y -= 1f; Main.dust[d].velocity *= 2f; } } if (Sadism) { int d = Dust.NewDust(npc.Center, 0, 0, 86, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 3f; Main.dust[d].scale += 1f; if (Main.rand.Next(4) < 3) { d = Dust.NewDust(npc.position, npc.width, npc.height, 86, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity.Y -= 1f; Main.dust[d].velocity *= 2f; Main.dust[d].scale += 0.5f; } } if (GodEater) { if (Main.rand.Next(7) < 6) { int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 86, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 3.5f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.2f; Main.dust[dust].velocity.Y -= 0.15f; if (Main.rand.Next(4) == 0) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } Lighting.AddLight(npc.position, 0.15f, 0.03f, 0.09f); } if (Chilled) { int d = Dust.NewDust(npc.Center, 0, 0, 15, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 3f; Main.dust[d].scale += 0.5f; if (Main.rand.Next(4) < 3) { d = Dust.NewDust(npc.position, npc.width, npc.height, 15, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity.Y -= 1f; Main.dust[d].velocity *= 2f; } } }
public override void CreateDust() { Lighting.AddLight((int)(projectile.Center.X / 16f), (int)(projectile.Center.Y / 16f), 1f, 1f, 10f); }
public override void PostAI() { Lighting.AddLight(projectile.position + projectile.velocity * 5, new Vector3(1f, .5f, .5f)); }
public override void AI() { Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.6f, .8f, 0.06f); int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.GoldCoin); npc.spriteDirection = npc.direction; Player target = Main.player[npc.target]; int distance = (int)Math.Sqrt((npc.Center.X - target.Center.X) * (npc.Center.X - target.Center.X) + (npc.Center.Y - target.Center.Y) * (npc.Center.Y - target.Center.Y)); if (distance < 320) { npc.ai[0]++; if (npc.ai[0] >= 100) { int type = ProjectileID.EyeBeam; int p = Terraria.Projectile.NewProjectile(npc.position.X, npc.position.Y, -(npc.position.X - target.position.X) / distance * 4, -(npc.position.Y - target.position.Y) / distance * 4, type, (int)((npc.damage * .5)), 0); Main.projectile[p].friendly = false; Main.projectile[p].hostile = true; npc.ai[0] = 0; } } int num67 = 10; num67 = 5; if (npc.ai[3] == -120f) { npc.velocity *= 0f; npc.ai[3] = 0f; Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 8); Vector2 vector14 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num68 = npc.oldPos[2].X + (float)npc.width * 0.5f - vector14.X; float num69 = npc.oldPos[2].Y + (float)npc.height * 0.5f - vector14.Y; float num70 = (float)Math.Sqrt((double)(num68 * num68 + num69 * num69)); num70 = 2f / num70; num68 *= num70; num69 *= num70; for (int num71 = 0; num71 < 20; num71++) //both loops spawn the pink dust. simply change the id :P { int num72 = Dust.NewDust(npc.position, npc.width, npc.height, DustID.GoldCoin, num68, num69, 200, default(Color), 2f); Main.dust[num72].noGravity = true; Dust expr_5C01_cp_0 = Main.dust[num72]; expr_5C01_cp_0.velocity.X = expr_5C01_cp_0.velocity.X * 2f; } for (int num73 = 0; num73 < 20; num73++) { int num74 = Dust.NewDust(npc.oldPos[2], npc.width, npc.height, DustID.GoldCoin, -num68, -num69, 200, default(Color), 2f); Main.dust[num74].noGravity = true; Dust expr_5C82_cp_0 = Main.dust[num74]; expr_5C82_cp_0.velocity.X = expr_5C82_cp_0.velocity.X * 2f; } } if (Main.netMode != 1 && npc.type == 120 && npc.ai[3] >= (float)num67) //npc allows for teleporting. moves npc to new position { int num214 = (int)Main.player[npc.target].position.X / 16; //calculates player postition int num215 = (int)Main.player[npc.target].position.Y / 16; int num216 = (int)npc.position.X / 16; int num217 = (int)npc.position.Y / 16; int num218 = 20; int num219 = 0; bool flag28 = false; if (Math.Abs(npc.position.X - Main.player[npc.target].position.X) + Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) { num219 = 100; flag28 = true; } while (!flag28) { if (num219 >= 100) { return; } num219++; int num220 = Main.rand.Next(num214 - num218, num214 + num218); int num221 = Main.rand.Next(num215 - num218, num215 + num218); for (int num222 = num221; num222 < num215 + num218; num222++) { if ((num222 < num215 - 4 || num222 > num215 + 4 || num220 < num214 - 4 || num220 > num214 + 4) && (num222 < num217 - 1 || num222 > num217 + 1 || num220 < num216 - 1 || num220 > num216 + 1) && Main.tile[num220, num222].nactive()) { bool flag29 = true; if (npc.type == 32 && Main.tile[num220, num222 - 1].wall == 0) { flag29 = false; } else if (Main.tile[num220, num222 - 1].lava()) //avoids lava { flag29 = false; } if (flag29 && Main.tileSolid[(int)Main.tile[num220, num222].type] && !Collision.SolidTiles(num220 - 1, num220 + 1, num222 - 4, num222 - 1)) //checks for a tile and if there is enough space { npc.position.X = (float)(num220 * 16 - npc.width / 2); npc.position.Y = (float)(num222 * 16 - npc.height); npc.netUpdate = true; npc.ai[3] = -120f; } } } } } }
public override void PostAll() { Lighting.AddLight(Projectile.Center, 1.8f, 0f, 0f); base.PostAll(); // Fades }
public override bool PreAI() { //THE END OF DAYS COMES AND HELL COMES TO EARTH AND IN THOSE DAYS MEN SHALL SEEK DEATH, AND SHALL IN NO WISE FIND IT; AND THEY SHALL DESIRE TO DIE, AND DEATH FLEETH FROM THEM. //UPON SOUNDING THE FIFTH TRUMPET, A STAR FELL FROM HEAVEN TO THE EARTH. HAVING CEASED TO BE A MINISTER OF CHRIST, HE WHO IS REPRESENTED BY THIS STAR BECOMES THE MINISTER OF THE DEVIL; AND LETS LOOSE THE POWERS OF HELL AGAINST THE CHURCHES OF CHRIST. ON THE OPENING OF THE BOTTOMLESS PIT, THERE AROSE A GREAT SMOKE. THE DEVIL CARRIES ON HIS DESIGNS BY BLINDING THE EYES OF MEN, BY PUTTING OUT LIGHT AND KNOWLEDGE, AND PROMOTING IGNORANCE AND ERROR. OUT OF THIS SMOKE THERE CAME A SWARM OF LOCUSTS, EMBLEMS OF THE DEVIL'S AGENTS, WHO PROMOTE SUPERSTITION, IDOLATRY, ERROR, AND CRUELTY. THE TREES AND THE GRASS, THE TRUE BELIEVERS, WHETHER YOUNG OR MORE ADVANCED, SHOULD BE UNTOUCHED. BUT A SECRET POISON AND INFECTION IN THE SOUL, SHOULD ROB MANY OTHERS OF PURITY, AND AFTERWARDS OF PEACE. THE LOCUSTS HAD NO POWER TO HURT THOSE WHO HAD THE SEAL OF GOD. GOD'S ALL-POWERFUL, DISTINGUISHING GRACE WILL KEEP HIS PEOPLE FROM TOTAL AND FINAL APOSTACY. THE POWER IS LIMITED TO A SHORT SEASON; BUT IT WOULD BE VERY SHARP. IN SUCH EVENTS THE FAITHFUL SHARE THE COMMON CALAMITY, BUT FROM THE PESTILENCE OF ERROR THEY MIGHT AND WOULD BE SAFE. WE COLLECT FROM SCRIPTURE, THAT SUCH ERRORS WERE TO TRY AND PROVE THE CHRISTIANS, 1CO 11:19. AND EARLY WRITERS PLAINLY REFER THIS TO THE FIRST GREAT HOST OF CORRUPTERS WHO OVERSPREAD THE CHRISTIAN CHURCH. npc.TargetClosest(true); Player player10 = Main.player[npc.target]; DespawnHandler(); Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.0f, 0.04f, 0.8f); if (npc.ai[0] == 0) { if (npc.life > (npc.lifeMax / 2)) { #region ai phase 1 movementCounter++; npc.TargetClosest(true); if (movementCounter < 800) { Vector2 direction = Main.player[npc.target].Center - npc.Center; direction.Normalize(); npc.velocity *= 0.985f; int dust2 = Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, 206, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f); Main.dust[dust2].noGravity = true; if (Math.Sqrt((npc.velocity.X * npc.velocity.X) + (npc.velocity.Y * npc.velocity.Y)) >= 7f) { int dust = Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, 206, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f); Main.dust[dust].noGravity = true; Main.dust[dust].scale = 2f; dust = Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, 206, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f); Main.dust[dust].noGravity = true; Main.dust[dust].scale = 2f; } if (Math.Sqrt((npc.velocity.X * npc.velocity.X) + (npc.velocity.Y * npc.velocity.Y)) < 13f) { if (Main.rand.Next(18) == 1) { direction.X = direction.X * Main.rand.Next(21, 27); direction.Y = direction.Y * Main.rand.Next(21, 27); npc.velocity.X = direction.X; npc.velocity.Y = direction.Y; } } // if (Math.Sqrt((npc.velocity.X * npc.velocity.X) + (npc.velocity.Y * npc.velocity.Y)) < 10f) // { // if (Main.rand.Next(18) == 1) // { // direction.X = direction.X * Main.rand.Next(20, 23); // direction.Y = direction.Y * Main.rand.Next(20, 23); // npc.velocity.X = direction.X; // npc.velocity.Y = direction.Y; // } // } if (movementCounter % 150 == 50) { Vector2 direction9 = Main.player[npc.target].Center - npc.Center; direction9.Normalize(); direction9.X *= 15f; direction9.Y *= 15f; int amountOfProjectiles = Main.rand.Next(7, 11); for (int i = 0; i < amountOfProjectiles; ++i) { float A = (float)Main.rand.Next(-250, 250) * 0.01f; float B = (float)Main.rand.Next(-250, 250) * 0.01f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction9.X + A, direction9.Y + B, ModContent.ProjectileType <CoreShard>(), 120, 1, Main.myPlayer, 0, 0); } } } if (movementCounter == 800) { npc.velocity.X = 0; npc.velocity.Y = 0; } if (movementCounter > 800) { if (movementCounter % 100 == 50) { Vector2 direction8 = Main.player[npc.target].Center - npc.Center; direction8.Normalize(); direction8.X *= 28f; direction8.Y *= 28f; int amountOfProjectiles = Main.rand.Next(10, 15); for (int i = 0; i < amountOfProjectiles; ++i) { float A = (float)Main.rand.Next(-250, 250) * 0.01f; float B = (float)Main.rand.Next(-250, 250) * 0.01f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction8.X + A, direction8.Y + B, ModContent.ProjectileType <SpiritShard>(), 90, 1, Main.myPlayer, 0, 0); } } float speed = 14f; float acceleration = 0.12f; Vector2 vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float xDir = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector2.X; float yDir = (float)(Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 120) - vector2.Y; float length = (float)Math.Sqrt(xDir * xDir + yDir * yDir); if (length > 400 && Main.expertMode) { ++speed; acceleration += 0.05F; if (length > 600) { ++speed; acceleration += 0.08F; if (length > 800) { ++speed; acceleration += 0.05F; } } } float num10 = speed / length; xDir = xDir * num10; yDir = yDir * num10; if (npc.velocity.X < xDir) { npc.velocity.X = npc.velocity.X + acceleration; if (npc.velocity.X < 0 && xDir > 0) { npc.velocity.X = npc.velocity.X + acceleration; } } else if (npc.velocity.X > xDir) { npc.velocity.X = npc.velocity.X - acceleration; if (npc.velocity.X > 0 && xDir < 0) { npc.velocity.X = npc.velocity.X - acceleration; } } if (npc.velocity.Y < yDir) { npc.velocity.Y = npc.velocity.Y + acceleration; if (npc.velocity.Y < 0 && yDir > 0) { npc.velocity.Y = npc.velocity.Y + acceleration; } } else if (npc.velocity.Y > yDir) { npc.velocity.Y = npc.velocity.Y - acceleration; if (npc.velocity.Y > 0 && yDir < 0) { npc.velocity.Y = npc.velocity.Y - acceleration; } } } if (movementCounter > 1400) { movementCounter = 0; } #endregion } else { #region Ai phase 2 if (!secondphase) { Main.NewText("BEHOLD MY TRUE POWER", 0, 80, 200, true); secondphase = true; } movementCounter++; npc.TargetClosest(true); if (movementCounter < 800) { if (movementCounter % 120 == 50) { Vector2 direction9 = Main.player[npc.target].Center - npc.Center; direction9.Normalize(); direction9.X *= 16f; direction9.Y *= 16f; int amountOfProjectiles = Main.rand.Next(7, 11); for (int i = 0; i < amountOfProjectiles; ++i) { float A = (float)Main.rand.Next(-250, 250) * 0.01f; float B = (float)Main.rand.Next(-250, 250) * 0.01f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction9.X + A, direction9.Y + B, ModContent.ProjectileType <CoreShard>(), 130, 1, Main.myPlayer, 0, 0); } } Vector2 direction = Main.player[npc.target].Center - npc.Center; direction.Normalize(); npc.velocity *= 0.983f; int dust2 = Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, 206, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f); Main.dust[dust2].noGravity = true; if (Math.Sqrt((npc.velocity.X * npc.velocity.X) + (npc.velocity.Y * npc.velocity.Y)) >= 7f) { int dust = Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, 206, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f); Main.dust[dust].noGravity = true; Main.dust[dust].scale = 2f; dust = Dust.NewDust(npc.position + npc.velocity, npc.width, npc.height, 206, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f); Main.dust[dust].noGravity = true; Main.dust[dust].scale = 2f; } if (Math.Sqrt((npc.velocity.X * npc.velocity.X) + (npc.velocity.Y * npc.velocity.Y)) < 14f) { if (Main.rand.Next(18) == 1) { direction.X = direction.X * Main.rand.Next(27, 31); direction.Y = direction.Y * Main.rand.Next(27, 31); npc.velocity.X = direction.X; npc.velocity.Y = direction.Y; } } // if (Math.Sqrt((npc.velocity.X * npc.velocity.X) + (npc.velocity.Y * npc.velocity.Y)) < 10f) // { // if (Main.rand.Next(18) == 1) // { // direction.X = direction.X * Main.rand.Next(20, 23); // direction.Y = direction.Y * Main.rand.Next(20, 23); // npc.velocity.X = direction.X; // npc.velocity.Y = direction.Y; // } // } } if (movementCounter == 800) //spawn portals { npc.velocity.X = 0; npc.velocity.Y = 0; } if (movementCounter > 800) { if (movementCounter % 75 == 50) { Vector2 direction8 = Main.player[npc.target].Center - npc.Center; direction8.Normalize(); direction8.X *= 24f; direction8.Y *= 28f; int amountOfProjectiles = Main.rand.Next(10, 15); for (int i = 0; i < amountOfProjectiles; ++i) { float A = (float)Main.rand.Next(-350, 350) * 0.01f; float B = (float)Main.rand.Next(-350, 350) * 0.01f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction8.X + A, direction8.Y + B, ModContent.ProjectileType <SpiritShard>(), 87, 1, npc.target, 0, 0); } } float speed = 15f; float acceleration = 0.13f; Vector2 vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float xDir = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector2.X; float yDir = (float)(Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 120) - vector2.Y; float length = (float)Math.Sqrt(xDir * xDir + yDir * yDir); if (length > 400 && Main.expertMode) { ++speed; acceleration += 0.05F; if (length > 600) { ++speed; acceleration += 0.08F; if (length > 800) { ++speed; acceleration += 0.05F; } } } float num10 = speed / length; xDir = xDir * num10; yDir = yDir * num10; if (npc.velocity.X < xDir) { npc.velocity.X = npc.velocity.X + acceleration; if (npc.velocity.X < 0 && xDir > 0) { npc.velocity.X = npc.velocity.X + acceleration; } } else if (npc.velocity.X > xDir) { npc.velocity.X = npc.velocity.X - acceleration; if (npc.velocity.X > 0 && xDir < 0) { npc.velocity.X = npc.velocity.X - acceleration; } } if (npc.velocity.Y < yDir) { npc.velocity.Y = npc.velocity.Y + acceleration; if (npc.velocity.Y < 0 && yDir > 0) { npc.velocity.Y = npc.velocity.Y + acceleration; } } else if (npc.velocity.Y > yDir) { npc.velocity.Y = npc.velocity.Y - acceleration; if (npc.velocity.Y > 0 && yDir < 0) { npc.velocity.Y = npc.velocity.Y - acceleration; } } } if (movementCounter > 1600) { for (int I = 0; I < 2; I++) { //cos = y, sin = x int portal = Projectile.NewProjectile((int)(Main.player[npc.target].Center.X + (Math.Sin(I * 180) * 500)), (int)(Main.player[npc.target].Center.Y + (Math.Cos(I * 180) * 500)), 0, 0, ModContent.ProjectileType <SpiritPortal>(), npc.damage, 1, npc.target, 0, 0); Projectile Eye = Main.projectile[portal]; Eye.ai[0] = I * 180; } movementCounter = 0; } #endregion } if (player10.active && !player10.dead) { #region teleportation if (Main.rand.Next(300) == 0) { int teleport = Projectile.NewProjectile(Main.player[npc.target].Center.X + Main.rand.Next(-600, 600), Main.player[npc.target].Center.Y + Main.rand.Next(-600, 600), 0, 0, ModContent.ProjectileType <SeerPortal>(), 55, 0, npc.target); Projectile tele = Main.projectile[teleport]; } #endregion } npc.ai[1]++; if (npc.ai[1] >= 180) { npc.TargetClosest(true); Vector2 dir = Main.player[npc.target].Center - npc.Center; dir.Normalize(); dir *= 8; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, dir.X, dir.Y, ModContent.ProjectileType <HauntedWisp>(), 60, 0, Main.myPlayer); npc.ai[1] = 0; } } return(false); }
public override void PostUpdate() { Lighting.AddLight(item.position, 1f, 1f, 1f); }
public override bool PreAI() { npc.netUpdate = true; npc.TargetClosest(true); Lighting.AddLight(npc.Center, 0.7F, 0.3F, 0.7F); Player player = Main.player[npc.target]; if (!player.active || player.dead || Main.dayTime) { npc.TargetClosest(false); npc.velocity.Y = -100; } if (npc.ai[0] == 0) // Flying around and shooting projectiles { #region Flying Movement float speed = 7f; float acceleration = 0.09f; Vector2 vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float xDir = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector2.X; float yDir = (float)(Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 120) - vector2.Y; float length = (float)Math.Sqrt(xDir * xDir + yDir * yDir); if (length > 400 && Main.expertMode) { ++speed; acceleration += 0.05F; if (length > 600) { ++speed; acceleration += 0.05F; if (length > 800) { ++speed; acceleration += 0.05F; } } } float num10 = speed / length; xDir = xDir * num10; yDir = yDir * num10; if (npc.velocity.X < xDir) { npc.velocity.X = npc.velocity.X + acceleration; if (npc.velocity.X < 0 && xDir > 0) { npc.velocity.X = npc.velocity.X + acceleration; } } else if (npc.velocity.X > xDir) { npc.velocity.X = npc.velocity.X - acceleration; if (npc.velocity.X > 0 && xDir < 0) { npc.velocity.X = npc.velocity.X - acceleration; } } if (npc.velocity.Y < yDir) { npc.velocity.Y = npc.velocity.Y + acceleration; if (npc.velocity.Y < 0 && yDir > 0) { npc.velocity.Y = npc.velocity.Y + acceleration; } } else if (npc.velocity.Y > yDir) { npc.velocity.Y = npc.velocity.Y - acceleration; if (npc.velocity.Y > 0 && yDir < 0) { npc.velocity.Y = npc.velocity.Y - acceleration; } } #endregion // Shadow Ball Shoot if (npc.ai[1] % 45 == 0) { Vector2 dir = Main.player[npc.target].Center - npc.Center; dir.Normalize(); dir *= 14; int newNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <ShadowBall>(), npc.whoAmI); Main.npc[newNPC].velocity = dir; } // Crystal Shadow Shoot. if (npc.ai[1] == 150) { for (int i = 0; i < 8; ++i) { bool expertMode = Main.expertMode; Vector2 targetDir = ((((float)Math.PI * 2) / 8) * i).ToRotationVector2(); targetDir.Normalize(); targetDir *= 3; int dmg = expertMode ? 23 : 37; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, targetDir.X, targetDir.Y, ModContent.ProjectileType <CrystalShadow>(), dmg, 0.5F, Main.myPlayer); } } // Shadowflamer Shoot if (npc.ai[1] % 110 == 0) { Vector2 dir = Main.player[npc.target].Center - npc.Center; dir += new Vector2(Main.rand.Next(-40, 41), Main.rand.Next(-40, 41)); dir.Normalize(); dir *= 12; int newNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <Shadowflamer>(), npc.whoAmI); Main.npc[newNPC].velocity = dir; } npc.ai[1]++; if (npc.ai[1] >= 300) { npc.ai[0] = 1; npc.ai[1] = 60; npc.ai[2] = 0; npc.ai[3] = 0; } // Rage Phase Switch if (npc.life <= 9000) { npc.ai[0] = 2; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; } } else if (npc.ai[0] == 1) // Charging. { npc.ai[1]++; if (Main.netMode != NetmodeID.MultiplayerClient) { if (npc.ai[1] % 45 == 0) { npc.TargetClosest(true); float speed = 10 + (2 * (int)(npc.life / 5000)); Vector2 vector2_1 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float dirX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector2_1.X; float dirY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector2_1.Y; float targetVel = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; float speedMultiplier = targetVel + (10f - targetVel); if (speedMultiplier < 6.0) { speedMultiplier = 6f; } if (speedMultiplier > 16.0) { speedMultiplier = 16f; } float speedX = dirX - Main.player[npc.target].velocity.X * speedMultiplier; float speedY = dirY - (Main.player[npc.target].velocity.Y * speedMultiplier / 4); speedX = speedX * (float)(1 + Main.rand.Next(-10, 11) * 0.01); speedY = speedY * (float)(1 + Main.rand.Next(-10, 11) * 0.01); float speedLength = (float)Math.Sqrt(speedX * speedX + speedY * speedY); float actualSpeed = speed / speedLength; npc.velocity.X = speedX * actualSpeed; npc.velocity.Y = speedY * actualSpeed; npc.velocity.X = npc.velocity.X + Main.rand.Next(-40, 41) * 0.1f; npc.velocity.Y = npc.velocity.Y + Main.rand.Next(-40, 41) * 0.1f; npc.netUpdate = true; } } if (npc.ai[1] >= 270) { npc.ai[0] = 0; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.velocity *= 0.3F; } } else if (npc.ai[0] == 2) // Continuous Charging. { if (npc.ai[1] == 0) // Flying Movement { bool expertMode = Main.expertMode; float speed = 38f; float acceleration = 1.55f; Vector2 vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num7 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector2.X; float num8 = (float)(Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 120) - vector2.Y; float num9 = (float)Math.Sqrt(num7 * num7 + num8 * num8); if (Main.rand.Next(100) == 6) { for (int i = 0; i < 8; ++i) { Vector2 targetDir = ((((float)Math.PI * 2) / 8) * i).ToRotationVector2(); targetDir.Normalize(); targetDir *= 3; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, targetDir.X, targetDir.Y, ModContent.ProjectileType <CrystalShadow>(), 26, 0.5F, Main.myPlayer); } } if (npc.life >= (npc.lifeMax / 2)) { if (Main.rand.Next(100) == 10) { Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 21); Vector2 direction = Main.player[npc.target].Center - npc.Center; direction.Normalize(); direction.X *= 12f; direction.Y *= 12f; int amountOfProjectiles = 1; for (int i = 0; i < amountOfProjectiles; ++i) { float A = (float)Main.rand.Next(-200, 200) * 0.01f; float B = (float)Main.rand.Next(-200, 200) * 0.01f; int damage = expertMode ? 23 : 37; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, direction.X + A, direction.Y + B, ModContent.ProjectileType <CrystalShadow>(), damage, 1, Main.myPlayer, 0, 0); } } } if (num9 > 400 && Main.expertMode) { ++speed; acceleration += 0.25F; if (num9 > 600) { ++speed; acceleration += 0.25F; if (num9 > 800) { ++speed; acceleration += 0.25F; } } } float num10 = speed / num9; float num11 = num7 * num10; float num12 = num8 * num10; if (npc.velocity.X < num11) { npc.velocity.X = npc.velocity.X + acceleration; if (npc.velocity.X < 0 && num11 > 0) { npc.velocity.X = npc.velocity.X + acceleration; } } else if (npc.velocity.X > num11) { npc.velocity.X = npc.velocity.X - acceleration; if (npc.velocity.X > 0 && num11 < 0) { npc.velocity.X = npc.velocity.X - acceleration; } } if (npc.velocity.Y < num12) { npc.velocity.Y = npc.velocity.Y + acceleration; if (npc.velocity.Y < 0 && num12 > 0) { npc.velocity.Y = npc.velocity.Y + acceleration; } } else if (npc.velocity.Y > num12) { npc.velocity.Y = npc.velocity.Y - acceleration; if (npc.velocity.Y > 0 && num12 < 0) { npc.velocity.Y = npc.velocity.Y - acceleration; } } npc.ai[2]++; if (npc.ai[2] >= 120) { npc.ai[1] = 1; npc.ai[2] = 0; } } else if (npc.ai[1] == 1) { npc.ai[2]++; if (npc.ai[2] % 45 == 0) { npc.TargetClosest(true); float speed = 15 + (2 * (int)(npc.life / 10000)); Vector2 vector2_1 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float dirX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector2_1.X; float dirY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector2_1.Y; float targetVel = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; float speedMultiplier = targetVel + (10f - targetVel); if (speedMultiplier < 35.0) { speedMultiplier = 35f; } if (speedMultiplier > 25.0) { speedMultiplier = 25f; } float speedX = dirX - Main.player[npc.target].velocity.X * speedMultiplier; float speedY = dirY - (Main.player[npc.target].velocity.Y * speedMultiplier / 4); speedX = speedX * (float)(1 + Main.rand.Next(-10, 11) * 0.01999999977648258); speedY = speedY * (float)(1 + Main.rand.Next(-10, 11) * 0.01999999977648258); float speedLength = (float)Math.Sqrt(speedX * speedX + speedY * speedY); float actualSpeed = speed / speedLength; npc.velocity.X = speedX * actualSpeed; npc.velocity.Y = speedY * actualSpeed; npc.velocity.X = npc.velocity.X + Main.rand.Next(-20, 21) * 0.5f; npc.velocity.Y = npc.velocity.Y + Main.rand.Next(-20, 21) * 0.5f; } if (Main.rand.Next(100) == 6) { for (int i = 0; i < 8; ++i) { Vector2 targetDir = ((((float)Math.PI * 2) / 8) * i).ToRotationVector2(); targetDir.Normalize(); targetDir *= 3; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, targetDir.X, targetDir.Y, ModContent.ProjectileType <CrystalShadow>(), 26, 0.5F, Main.myPlayer); } } if (npc.ai[2] >= 270) { npc.ai[1] = 0; npc.ai[2] = 0; npc.velocity *= 0.3F; } } // Circle code. if (npc.localAI[0] < 1) { npc.localAI[0] += 0.01F; } npc.localAI[1] += 0.03F; npc.ai[3]++; if (npc.ai[3] >= 6) { for (int i = 0; i < 255; ++i) { if (Main.player[i].active && !Main.player[i].dead) { if ((Main.player[i].Center - npc.Center).Length() <= 200) { //Main.player[i].Hurt(1, 0, false, false, " was evaporated...", false, 1); commed out because this needs work Main.player[i].AddBuff(BuffID.Darkness, 330); } } } npc.ai[3] = 0; } } else if (npc.ai[0] == 3) { npc.velocity *= 0.97F; npc.alpha += 3; if (npc.alpha >= 255) { npc.active = false; } } if (!Main.player[npc.target].active || Main.player[npc.target].dead) { npc.TargetClosest(true); if (!Main.player[npc.target].active || Main.player[npc.target].dead) { npc.ai[0] = 3; } } return(true); }
public virtual void Effects() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.05f / 255f, (255 - projectile.alpha) * 0.05f / 255f); }
public override void AI() { Lighting.AddLight(projectile.Center, 0, 0f, .15f); if (projectile.frameCounter > 5) { projectile.frame++; projectile.frameCounter = 0; if (projectile.frame > 3) { projectile.frame = 0; } } if (!NPC.AnyNPCs(ModContent.NPCType <ObserverVoid>())) { projectile.active = false; } if (body == -1) { int npcID = BaseAI.GetNPC(projectile.Center, ModContent.NPCType <ObserverVoid>(), 400f, null); if (npcID >= 0) { body = npcID; } } if (body == -1) { return; } NPC observer = Main.npc[body]; if (observer == null || observer.life <= 0 || !observer.active || observer.type != ModContent.NPCType <ObserverVoid>()) { projectile.active = false; return; } Player player = Main.player[observer.target]; pos = observer.Center; for (int m = projectile.oldPos.Length - 1; m > 0; m--) { projectile.oldPos[m] = projectile.oldPos[m - 1]; } projectile.oldPos[0] = projectile.position; int starNumber = ((ObserverVoid)observer.modNPC).StarCount; if (((ObserverVoid)observer.modNPC).internalAI[0] == 0) { projectile.timeLeft = 180; float dist = ((ObserverVoid)observer.modNPC).internalAI[1]; if (rotValue == -1f) { rotValue = projectile.ai[0] % starNumber * ((float)Math.PI * 2f / starNumber); } rotValue += 0.08f; while (rotValue > (float)Math.PI * 2f) { rotValue -= (float)Math.PI * 2f; } for (int m = projectile.oldPos.Length - 1; m > 0; m--) { projectile.oldPos[m] = projectile.oldPos[m - 1]; } projectile.oldPos[0] = projectile.position; projectile.Center = BaseUtility.RotateVector(observer.Center, observer.Center + new Vector2(dist, 0f), rotValue); if (projectile.ai[1]++ > 180) { if (Collision.CanHit(projectile.position, projectile.width, projectile.height, player.Center, player.width, player.height)) { Vector2 fireTarget = projectile.Center; float rot = BaseUtility.RotationTo(projectile.Center, player.Center); fireTarget = BaseUtility.RotateVector(projectile.Center, fireTarget, rot); BaseAI.FireProjectile(player.Center, fireTarget, mod.ProjType("BlackHoleProj"), damage, 0f, 4f); } projectile.ai[1] = 0; } } else if (((ObserverVoid)observer.modNPC).internalAI[0] == 1) { projectile.Kill(); } }
public override void AI() //vanilla code echprimebegone { float num1 = 5f; float num2 = 250f; float num3 = 6f; Vector2 vector2_1 = new Vector2(8f, 10f); float num4 = 1.2f; Vector3 rgb = new Vector3(0.7f, 0.1f, 0.5f); int num5 = 4 * projectile.MaxUpdates; int Type1 = Utils.SelectRandom <int>(Main.rand, new int[5] { 242, 73, 72, 71, (int)byte.MaxValue }); int Type2 = (int)byte.MaxValue; if ((double)projectile.ai[1] == 0.0) { projectile.ai[1] = 1f; projectile.localAI[0] = (float)-Main.rand.Next(48); Main.PlaySound(SoundID.Item34, projectile.position); } else if ((double)projectile.ai[1] == 1.0 && projectile.owner == Main.myPlayer) { } else if ((double)projectile.ai[1] > (double)num1) { } if ((double)projectile.ai[1] >= 1.0 && (double)projectile.ai[1] < (double)num1) { ++projectile.ai[1]; if ((double)projectile.ai[1] == (double)num1) { projectile.ai[1] = 1f; } } projectile.alpha = projectile.alpha - 40; if (projectile.alpha < 0) { projectile.alpha = 0; } projectile.spriteDirection = projectile.direction; projectile.frameCounter = projectile.frameCounter + 1; if (projectile.frameCounter >= num5) { projectile.frame = projectile.frame + 1; projectile.frameCounter = 0; if (projectile.frame >= 4) { projectile.frame = 0; } } Lighting.AddLight(projectile.Center, rgb); projectile.rotation = projectile.velocity.ToRotation(); ++projectile.localAI[0]; if ((double)projectile.localAI[0] == 48.0) { projectile.localAI[0] = 0.0f; } else if (projectile.alpha == 0) { for (int index1 = 0; index1 < 2; ++index1) { Vector2 vector2_2 = Vector2.UnitX * -30f; Vector2 vector2_3 = -Vector2.UnitY.RotatedBy((double)projectile.localAI[0] * 0.130899697542191 + (double)index1 * 3.14159274101257, new Vector2()) * vector2_1 - projectile.rotation.ToRotationVector2() * 10f; int index2 = Dust.NewDust(projectile.Center, 0, 0, Type2, 0.0f, 0.0f, 160, new Color(), 1f); Main.dust[index2].scale = num4; Main.dust[index2].noGravity = true; Main.dust[index2].position = projectile.Center + vector2_3 + projectile.velocity * 2f; Main.dust[index2].velocity = Vector2.Normalize(projectile.Center + projectile.velocity * 2f * 8f - Main.dust[index2].position) * 2f + projectile.velocity * 2f; } } if (Main.rand.Next(12) == 0) { for (int index1 = 0; index1 < 1; ++index1) { Vector2 vector2_2 = -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_2 * (float)projectile.width / 2f + projectile.velocity * 2f; Main.dust[index2].fadeIn = 0.9f; } } if (Main.rand.Next(64) == 0) { for (int index1 = 0; index1 < 1; ++index1) { Vector2 vector2_2 = -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_2 * (float)projectile.width / 2f; if (Main.rand.Next(2) == 0) { Main.dust[index2].fadeIn = 1.4f; } } } if (Main.rand.Next(4) == 0) { for (int index1 = 0; index1 < 2; ++index1) { Vector2 vector2_2 = -Vector2.UnitX.RotatedByRandom(0.785398185253143).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()); int index2 = Dust.NewDust(projectile.position, projectile.width, projectile.height, Type1, 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_2 * (float)projectile.width / 2f; if (Main.rand.Next(2) == 0) { Main.dust[index2].fadeIn = 1.4f; } } } if (Main.rand.Next(12) == 0 && projectile.type == 634) { Vector2 vector2_2 = -Vector2.UnitX.RotatedByRandom(0.196349546313286).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()); int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, Type2, 0.0f, 0.0f, 100, new Color(), 1f); Main.dust[index].velocity *= 0.3f; Main.dust[index].position = projectile.Center + vector2_2 * (float)projectile.width / 2f; Main.dust[index].fadeIn = 0.9f; Main.dust[index].noGravity = true; } if (Main.rand.Next(3) == 0 && projectile.type == 635) { Vector2 vector2_2 = -Vector2.UnitX.RotatedByRandom(0.196349546313286).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2()); int index = Dust.NewDust(projectile.position, projectile.width, projectile.height, Type2, 0.0f, 0.0f, 100, new Color(), 1f); Main.dust[index].velocity *= 0.3f; Main.dust[index].position = projectile.Center + vector2_2 * (float)projectile.width / 2f; Main.dust[index].fadeIn = 1.2f; Main.dust[index].scale = 1.5f; Main.dust[index].noGravity = true; } }
public override void PostUpdate() { Lighting.AddLight(item.Center, 0f, .749f, 1f); }
public override void AI() { alphaCounter += .04f; projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; Lighting.AddLight(new Vector2(projectile.Center.X, projectile.Center.Y), 0.075f * 2, 0.231f * 2, 0.255f * 2); projectile.frameCounter++; projectile.spriteDirection = -projectile.direction; if (projectile.frameCounter >= 10) { projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; projectile.frameCounter = 0; } float num1 = 10f; float num2 = 5f; float num3 = 40f; num1 = 10f; num2 = 7.5f; if (projectile.timeLeft > 30 && projectile.alpha > 0) { projectile.alpha -= 25; } if (projectile.timeLeft > 30 && projectile.alpha < 128 && Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { projectile.alpha = 128; } if (projectile.alpha < 0) { projectile.alpha = 0; } if (++projectile.frameCounter > 4) { projectile.frameCounter = 0; if (++projectile.frame >= 4) { projectile.frame = 0; } } ++projectile.ai[1]; double num5 = (double)projectile.ai[1] / 180.0; int index1 = (int)projectile.ai[0]; if (index1 >= 0 && Main.player[index1].active && !Main.player[index1].dead) { if (projectile.Distance(Main.player[index1].Center) <= num3) { return; } Vector2 unitY = projectile.DirectionTo(Main.player[index1].Center); if (unitY.HasNaNs()) { unitY = Vector2.UnitY; } projectile.velocity = (projectile.velocity * (num1 - 1f) + unitY * num2) / num1; } else { if (projectile.timeLeft > 30) { projectile.timeLeft = 30; } if (projectile.ai[0] == -1f) { return; } projectile.ai[0] = -1f; projectile.netUpdate = true; } }
public override void AI() { dustTimer++; healTimer++; npc.TargetClosest(false); Player player = Main.player[npc.target]; npc.spriteDirection = npc.direction; Lighting.AddLight(npc.position, 0.0149f / 4 * npc.life, 0.0142f / 4 * npc.life, 0.0207f / 4 * npc.life); if (npc.active && player.active && !shieldSpawned) { shieldSpawned = true; int shield1 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y + (npc.height / 2), ModContent.NPCType <Cystal_Shield>()); Main.npc[shield1].Center += new Vector2(0, 150).RotatedBy(MathHelper.ToRadians(90)); Main.npc[shield1].ai[1] = npc.whoAmI; int shield2 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y + (npc.height / 2), ModContent.NPCType <Cystal_Shield>()); Main.npc[shield2].Center += new Vector2(0, 150).RotatedBy(MathHelper.ToRadians(180)); Main.npc[shield2].ai[1] = npc.whoAmI; int shield3 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y + (npc.height / 2), ModContent.NPCType <Cystal_Shield>()); Main.npc[shield3].Center += new Vector2(0, 150).RotatedBy(MathHelper.ToRadians(270)); Main.npc[shield3].ai[1] = npc.whoAmI; int shield4 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y + (npc.height / 2), ModContent.NPCType <Cystal_Shield>()); Main.npc[shield4].Center += new Vector2(0, 150).RotatedBy(MathHelper.ToRadians(360)); Main.npc[shield4].ai[1] = npc.whoAmI; } if (npc.DistanceSQ(player.Center) < 150 * 150) { Filters.Scene.Activate("CystalTower", player.position); Filters.Scene.Activate("CystalBloodMoon", player.position); player.AddBuff(ModContent.BuffType <Crystallization>(), 2); } else { Filters.Scene.Deactivate("CystalTower", player.position); Filters.Scene.Deactivate("CystalBloodMoon", player.position); } for (int i = 0; i < 200; i++) { NPC other = Main.npc[i]; if (other.active && other.type != ModContent.NPCType <Cystal>() && other.type != ModContent.NPCType <Cystal_Shield>()) { if (npc.DistanceSQ(other.Center) < 150 * 150 && healTimer % 60 == 0) { if (other.life < other.lifeMax - 10) { other.life += 10; other.HealEffect(10, true); } } if (npc.DistanceSQ(other.Center) < 1200 * 1200 && other.life < other.lifeMax - 10 && other.type == Main.npc[(int)npc.ai[1]].type && other.active && !other.friendly) { npc.SimpleFlyMovement(npc.DirectionTo(Main.npc[(int)npc.ai[1]].Center + new Vector2(0.0f, -100f)) * 5f, 0.9f); return; } } } float playerDistance = player.DistanceSQ(npc.Center); if (playerDistance <= 150 * 150f && player.active) { float x = player.Center.X - npc.Center.X; float y = player.Center.Y - npc.Center.Y; float length = 8f / (float)Math.Sqrt(x * x + y * y); npc.velocity.X = x * length * -1 * 0.3f; npc.velocity.Y = y * length * -1 * 0.3f; npc.spriteDirection = -1; npc.direction = -1; } if (playerDistance <= 150 * 150f && playerDistance > 100 * 100f) { npc.velocity = Vector2.Zero; } if (playerDistance > 150f && player.active) { const float MoveSpeed = 0.25f; float x = player.Center.X - npc.Center.X; float y = player.Center.Y - npc.Center.Y; float distance = x * x + y * y; if (player == Main.player[npc.target]) { float oldVelX = npc.velocity.X; float oldVelY = npc.velocity.Y; if (distance >= 20 * 20f) { float magnitude = 4f / distance; oldVelX = x * magnitude; oldVelY = y * magnitude; } if (npc.velocity.X < oldVelX) { npc.velocity.X += MoveSpeed; if (npc.velocity.X < 0 && oldVelX > 0) { npc.velocity.X += MoveSpeed * 2f; } } else if (npc.velocity.X > oldVelX) { npc.velocity.X -= MoveSpeed; if (npc.velocity.X > 0 && oldVelX < 0) { npc.velocity.X -= MoveSpeed * 2f; } } if (npc.velocity.Y < oldVelY) { npc.velocity.Y += MoveSpeed; if (npc.velocity.Y < 0 && oldVelY > 0) { npc.velocity.Y += MoveSpeed * 2f; } } else if (npc.velocity.Y > oldVelY) { npc.velocity.Y -= MoveSpeed; if (npc.velocity.Y > 0 && oldVelY < 0) { npc.velocity.Y -= MoveSpeed * 2f; } } } } }
private void RainbowDusts(int radius, Vector2 position, int dustStyle, int xOffsetLeft, int xOffsetRight) { Dust dust; Vector2 updatedPosition; for (int x = -radius; x <= radius; x++) //Starts on the X Axis on the left { for (int y = -radius; y <= 0; y++) //Starts on the Y Axis on the top { int xPosition = (int)(x + position.X / 16.0f); int yPosition = (int)(y + position.Y / 16.0f); updatedPosition = new Vector2(xPosition * 16.0f, yPosition * 16.0f); Lighting.AddLight(new Vector2(xPosition * 16.0f, yPosition * 16.0f), new Vector3(.9f, 9f, 9f)); Lighting.maxX = 1; Lighting.maxY = 1; if (WorldGen.TileEmpty(xPosition, yPosition)) //Runs when a tile is empty { if (Math.Sqrt(x * x + y * y) <= radius - 8 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Inner Circle { //Inner circle is ignored } else if (Math.Sqrt(x * x + y * y) <= radius - 7 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Violet { dust = Terraria.Dust.NewDustPerfect(updatedPosition, 76, new Vector2(0f, 0f), 0, new Color(184, 0, 255), 3f); dust.noGravity = true; } else if (Math.Sqrt(x * x + y * y) <= radius - 6 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Indigo { dust = Terraria.Dust.NewDustPerfect(updatedPosition, 76, new Vector2(0f, 0f), 0, new Color(234, 0, 255), 3f); dust.noGravity = true; } else if (Math.Sqrt(x * x + y * y) <= radius - 5 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Blue { dust = Terraria.Dust.NewDustPerfect(updatedPosition, 76, new Vector2(0f, 0f), 0, new Color(0, 92, 255), 3f); dust.noGravity = true; } else if (Math.Sqrt(x * x + y * y) <= radius - 4 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Green { dust = Terraria.Dust.NewDustPerfect(updatedPosition, 76, new Vector2(0f, 0f), 0, new Color(0, 255, 42), 3f); dust.noGravity = true; } else if (Math.Sqrt(x * x + y * y) <= radius - 3 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Yellow { dust = Terraria.Dust.NewDustPerfect(updatedPosition, 76, new Vector2(0f, 0f), 0, new Color(255, 251, 0), 3f); dust.noGravity = true; } else if (Math.Sqrt(x * x + y * y) <= radius - 2 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Orange { dust = Terraria.Dust.NewDustPerfect(updatedPosition, 76, new Vector2(0f, 0f), 0, new Color(255, 150, 0), 3f); dust.noGravity = true; } else if (Math.Sqrt(x * x + y * y) <= radius - 1 + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Red { dust = Terraria.Dust.NewDustPerfect(updatedPosition, 76, new Vector2(0f, 0f), 0, new Color(255, 0, 0), 3f); dust.noGravity = true; } else if (Math.Sqrt(x * x + y * y) <= radius + 0.5 && (WorldGen.InWorld(xPosition, yPosition))) //Clouds { dust = Main.dust[Terraria.Dust.NewDust(new Vector2(position.X - (radius * 16.0f) - (170 / 4), position.Y), 170, 110, 86, 0f, 0f, 0, new Color(255, 255, 255), 5f)]; dust.noGravity = true; dust.noLight = false; dust.shader = GameShaders.Armor.GetSecondaryShader(79, Main.LocalPlayer); dust = Main.dust[Terraria.Dust.NewDust(new Vector2(position.X + (radius * 16.0f) - 160, position.Y), 170, 110, 86, 0f, 0f, 0, new Color(255, 255, 255), 5f)]; dust.noGravity = true; dust.noLight = false; dust.shader = GameShaders.Armor.GetSecondaryShader(79, Main.LocalPlayer); } } } } }
public override void AI() { Lighting.AddLight(projectile.Center, 0.5f, 0f, .5f); if (!NPC.AnyNPCs(ModContent.NPCType <Novacore>())) { projectile.active = false; } if (body == -1) { int npcID = BaseAI.GetNPC(projectile.Center, ModContent.NPCType <Novacore>(), 400f, null); if (npcID >= 0) { body = npcID; } } if (body == -1) { return; } NPC novacore = Main.npc[body]; if (novacore == null || novacore.life <= 0 || !novacore.active || novacore.type != ModContent.NPCType <Novacore>()) { projectile.active = false; return; } Player player = Main.player[novacore.target]; pos = novacore.Center; if (projectile.localAI[0] == 0) { starNumber = ((Novacore)novacore.modNPC).TurretCount(); projectile.localAI[0]++; projectile.netUpdate = true; } projectile.rotation += .06f; float dist = ((Novacore)novacore.modNPC).OrbitterDist; if (rotValue == -1f) { rotValue = projectile.ai[0] % starNumber * ((float)Math.PI * 2f / starNumber); } rotValue += 0.04f; while (rotValue > (float)Math.PI * 2f) { rotValue -= (float)Math.PI * 2f; } projectile.Center = BaseUtility.RotateVector(novacore.Center, novacore.Center + new Vector2(dist, 0f), rotValue); if (projectile.ai[1]++ > 180) { if (Collision.CanHit(projectile.position, projectile.width, projectile.height, player.Center, player.width, player.height)) { Vector2 fireTarget = projectile.Center; float rot = BaseUtility.RotationTo(projectile.Center, player.Center); fireTarget = BaseUtility.RotateVector(projectile.Center, fireTarget, rot); BaseAI.FireProjectile(player.Center, fireTarget, ModContent.ProjectileType <NovaBlast>(), projectile.damage / 4, 0f, 4f); } projectile.ai[1] = 0; } }
public virtual void CreateDust() { Lighting.AddLight((int)(projectile.Center.X / 16f), (int)(projectile.Center.Y / 16f), 0.6f, 0.9f, 0.3f); }
public override void AI() { Lighting.AddLight(projectile.Top, Color.LightBlue.ToVector3()); }