public override void AI() { const int startup = 100; if (Projectile.localAI[0] == 0) { Projectile.localAI[0] = 1; Projectile.localAI[1] = Projectile.velocity.Length() / startup; Projectile.hide = false; Projectile.rotation = 2f * Main.rand.NextFloat(MathHelper.TwoPi) * (Main.rand.NextBool() ? -1 : 1); Projectile.frame = Main.rand.Next(Main.projFrames[Projectile.type]); } if (++dustTimer == 15) { MakeDust(); SoundEngine.PlaySound(SoundID.Item71, Projectile.Center); } if (Projectile.ai[0] == -1) //fly forward { if (++Projectile.localAI[0] <= startup) { Projectile.velocity = (Projectile.velocity.Length() - Projectile.localAI[1]) * Vector2.Normalize(Projectile.velocity); Projectile.rotation = MathHelper.Lerp(Projectile.rotation, Projectile.ai[1] > 0 ? 0 : MathHelper.Pi, 0.05f); Projectile.spriteDirection = (int)Projectile.ai[1]; if (Projectile.localAI[0] == startup) SoundEngine.PlaySound(SoundID.Item71, Projectile.Center); } else { Projectile.velocity = 36f * Projectile.ai[1] * Vector2.UnitX; Projectile.rotation = Projectile.velocity.ToRotation(); } } else //hover around mothron { NPC npc = FargoSoulsUtil.NPCExists(Projectile.ai[0], NPCID.Mothron); if (npc == null || (npc.ai[0] < 3f && dustTimer > 15)) { Projectile.Kill(); return; } else { Projectile.timeLeft++; const float rotationPerTick = MathHelper.TwoPi / 60f; Projectile.spriteDirection = Math.Sign(Projectile.ai[1]); Projectile.ai[1] += rotationPerTick * Projectile.spriteDirection; Projectile.rotation = Projectile.ai[1]; float distance = 120; if (Projectile.spriteDirection < 0) distance *= 2; Projectile.Center = npc.Center + distance * Projectile.ai[1].ToRotationVector2(); if (npc.ai[0] < 4f) Projectile.alpha -= 4; } } Projectile.alpha -= 4; if (Projectile.alpha < 0) Projectile.alpha = 0; }
//TODO unused private void VisitRegisterWebpage(UIMouseEvent evt, UIElement listeningElement) { SoundEngine.PlaySound(10); Process.Start(REGISTER_URL); }
private void BackClick(UIMouseEvent evt, UIElement listeningElement) { SoundEngine.PlaySound(11); Main.menuMode = _backMenu; }
private void GoBackClick(UIMouseEvent evt, UIElement listeningElement) { SoundEngine.PlaySound(11); Main.menuMode = ((!Main.menuMultiplayer) ? 1 : 12); }
private void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement) { SoundEngine.PlaySound(12); ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171); ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver; }
public override bool PreAI(NPC npc) { bool result = base.PreAI(npc); EModeGlobalNPC.deerBoss = npc.whoAmI; if (FargoSoulsWorld.SwarmActive) { return(result); } const int MaxBerserkTime = 600; BerserkSpeedupTimer -= 1; if (npc.localAI[3] > 0 || EnteredPhase3) { npc.localAI[2]++; //cry about it } const int TeleportThreshold = 780; if (npc.ai[0] != 0) { npc.alpha -= 10; if (npc.alpha < 0) { npc.alpha = 0; } if (EnteredPhase3) { npc.localAI[2]++; } } TeleportTimer++; if (EnteredPhase3) { TeleportTimer++; } if (Main.LocalPlayer.active && !Main.LocalPlayer.ghost && !Main.LocalPlayer.dead && npc.Distance(Main.LocalPlayer.Center) < 1200) { Main.LocalPlayer.AddBuff(ModContent.BuffType <LowGround>(), 2); } switch ((int)npc.ai[0]) { case 0: //walking at player if (TeleportTimer < TeleportThreshold) { if (EnteredPhase3) { npc.position.X += npc.velocity.X; } if (npc.velocity.Y == 0) { if (EnteredPhase2) { npc.position.X += npc.velocity.X; } if (BerserkSpeedupTimer > 0) { npc.position.X += npc.velocity.X * 4f * BerserkSpeedupTimer / MaxBerserkTime; } } } if (EnteredPhase2) { if (!EnteredPhase3 && npc.life < npc.lifeMax * .33) { npc.ai[0] = 3; npc.ai[1] = 0; npc.netUpdate = true; break; } if (TeleportTimer > TeleportThreshold) { npc.velocity.X *= 0.9f; npc.dontTakeDamage = true; npc.localAI[1] = 0; //reset walls attack counter if (EnteredPhase2 && Main.LocalPlayer.active && !Main.LocalPlayer.ghost && !Main.LocalPlayer.dead) { FargoSoulsUtil.AddDebuffFixedDuration(Main.LocalPlayer, BuffID.Darkness, 2); FargoSoulsUtil.AddDebuffFixedDuration(Main.LocalPlayer, BuffID.Blackout, 2); } if (npc.alpha == 0) { SoundEngine.PlaySound(SoundID.Roar, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { const int max = 12; for (int i = 0; i < 12; i++) { Vector2 spawnPos = Main.player[npc.target].Center + 16 * Main.rand.NextFloat(6, 36) * Vector2.UnitX.RotatedBy(MathHelper.TwoPi / max * (i + Main.rand.NextFloat())); Projectile.NewProjectile(npc.GetSource_FromThis(), spawnPos, Vector2.Zero, ModContent.ProjectileType <DeerclopsHand>(), 0, 0f, Main.myPlayer, npc.target); } } } npc.alpha += 5; if (npc.alpha > 255) { npc.alpha = 255; npc.localAI[3] = 30; if (npc.HasPlayerTarget) //teleport { float distance = 16 * 14 * Math.Sign(npc.Center.X - Main.player[npc.target].Center.X); distance *= -1f; //alternate back and forth if (TeleportTimer == TeleportThreshold + 10) //introduce randomness { if (Main.rand.NextBool()) { distance *= -1f; } if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, number: npc.whoAmI); } DoLaserAttack = !DoLaserAttack; //guarantee he alternates wall attacks at some point in the fight NetSync(npc); } npc.Bottom = Main.player[npc.target].Bottom + distance * Vector2.UnitX; npc.direction = Math.Sign(Main.player[npc.target].Center.X - npc.Center.X); npc.velocity.X = 3.4f * npc.direction; npc.velocity.Y = 0; int addedThreshold = 180; if (EnteredPhase3) { addedThreshold -= 30; } if (FargoSoulsWorld.MasochistModeReal) { addedThreshold -= 30; } if (TeleportTimer > TeleportThreshold + addedThreshold) { TeleportTimer = 0; npc.velocity.X = 0; npc.ai[0] = 4; npc.ai[1] = 0; NetSync(npc); if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, number: npc.whoAmI); } } } } else { TeleportTimer = TeleportThreshold; if (npc.localAI[3] > 0) { npc.localAI[3] -= 3; //remove visual effect } } return(false); } } else if (npc.life < npc.lifeMax * .66) { npc.ai[0] = 3; npc.ai[1] = 0; npc.netUpdate = true; } break; case 1: //ice wave, npc.localai[1] counts them, attacks at ai1=30, last spike 52, ends at ai1=80 if (npc.ai[1] < 30) { if (FargoSoulsWorld.MasochistModeReal) { npc.ai[1] += 0.5f; npc.frameCounter += 0.5; } } break; case 2: //debris attack break; case 3: //roar at 30, ends at ai1=60 if (!FargoSoulsWorld.MasochistModeReal && npc.ai[1] < 30) { npc.ai[1] -= 0.5f; npc.frameCounter -= 0.5; } if (EnteredPhase2) { npc.localAI[1] = 0; //ensure this is always the same npc.localAI[3] = 30; //go invul if (npc.ai[1] > 30) { Main.dayTime = false; Main.time = 16200; //midnight, to help teleport visual } } else if (npc.life < npc.lifeMax * .66) { EnteredPhase2 = true; NetSync(npc); } if (EnteredPhase3) { if (!Main.dedServ) { Main.LocalPlayer.GetModPlayer <FargoSoulsPlayer>().Screenshake = 2; } if (npc.ai[1] > 30) //roaring { if (npc.HasValidTarget) //fly over player { npc.position = Vector2.Lerp(npc.position, Main.player[npc.target].Center - 450 * Vector2.UnitY, 0.2f); } } } else if (npc.life < npc.lifeMax * .33) { EnteredPhase3 = true; NetSync(npc); } if (EnteredPhase3 || FargoSoulsWorld.MasochistModeReal) { BerserkSpeedupTimer = MaxBerserkTime; } break; case 4: //both sides ice wave, attacks at ai1=50, last spike 70, ends at ai1=90 { int cooldown = 100; //stops deerclops from teleporting while old ice walls are still there if (EnteredPhase3) { cooldown *= 2; } if (TeleportTimer > TeleportThreshold - cooldown) { TeleportTimer = TeleportThreshold - cooldown; } if (EnteredPhase2 && npc.ai[1] == 0) { if (npc.alpha == 0) //i.e. dont randomize when coming out of tp { DoLaserAttack = Main.rand.NextBool(); } NetSync(npc); if (DoLaserAttack && Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.type); } } Vector2 eye = npc.Center + new Vector2(64 * npc.direction, -24f) * npc.scale; if (FargoSoulsWorld.MasochistModeReal) { const int desiredStartup = 30; //effectively changes startup from 50 to this value const int threshold = 50 - desiredStartup / 2; if (npc.ai[1] < threshold) { npc.ai[1]++; } } if (DoLaserAttack && npc.ai[1] >= 70) { if (EnteredPhase3) { const float baseIncrement = 0.33f; float increment = baseIncrement; //if (FargoSoulsWorld.MasochistModeReal) increment *= 2; if (npc.ai[1] == 70) //shoot laser { float time = (90 - 70) / baseIncrement - 5; time *= 5; //account for the ray having extra updates float rotation = MathHelper.Pi * (FargoSoulsWorld.MasochistModeReal ? 1f : 0.8f) / time * -npc.direction; if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(npc.GetSource_FromThis(), eye, Vector2.UnitY, ModContent.ProjectileType <DeerclopsDeathray>(), FargoSoulsUtil.ScaledProjectileDamage(npc.damage, 2f), 0f, Main.myPlayer, rotation, time); } } npc.ai[1] += increment; //more endlag than normal if (npc.ai[1] < 90) { return(false); //stop deerclops from turning around } } else { npc.ai[1] += 0.33f; //more endlag than normal if (npc.ai[1] >= 89) { npc.ai[0] = 2; //force debris attack instead npc.ai[1] = 0; npc.frameCounter = 0; npc.netUpdate = true; break; } } if (npc.ai[1] < 90) { return(false); //stop deerclops from turning around } } } break; case 6: //trying to return home npc.TargetClosest(); if (npc.ai[1] > 120 && (!npc.HasValidTarget || npc.Distance(Main.player[npc.target].Center) > 1600)) { if (Main.netMode != NetmodeID.MultiplayerClient) //force despawn { npc.ai[0] = 8f; npc.ai[1] = 0.0f; npc.localAI[1] = 0.0f; npc.netUpdate = true; } } break; default: break; } if (EnteredPhase3 && !(npc.ai[0] == 0 && npc.alpha > 0)) { npc.localAI[3] += 3; if (npc.localAI[3] > 30) { npc.localAI[3] = 30; } } //FargoSoulsUtil.PrintAI(npc); EModeUtils.DropSummon(npc, "DeerThing2", NPC.downedDeerclops, ref DroppedSummon); return(result); }
public override void AI() { //dust! int dustId = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 15, 0f, 0f, 100, default(Color), 2f); Main.dust[dustId].noGravity = true; int dustId3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 15, 0f, 0f, 100, default(Color), 2f); Main.dust[dustId3].noGravity = true; Player player = Main.player[Projectile.owner]; /*if (Projectile.owner == Main.myPlayer && !player.controlUseItem) * { * Projectile.Kill(); * return; * }*/ if (player.dead || !player.active) { Projectile.Kill(); return; } //Vector2 ownerMountedCenter = player.RotatedRelativePoint(player.MountedCenter); //Projectile.direction = player.direction; player.heldProj = Projectile.whoAmI; player.itemTime = 2; player.itemAnimation = 2; if (++Projectile.localAI[0] > 10) { Projectile.localAI[0] = 0; SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); if (Projectile.owner == Main.myPlayer) { Vector2 speed = Vector2.UnitX.RotatedByRandom(2 * Math.PI) * Main.rand.NextFloat(9f, 12f); float ai1 = Main.rand.Next(30, 60); int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position + Main.rand.NextVector2Square(0f, Projectile.width), speed, ModContent.ProjectileType <PhantasmalEyeHoming>(), Projectile.damage, Projectile.knockBack / 2, Projectile.owner, -1, ai1); if (p != Main.maxProjectiles) { Main.projectile[p].DamageType = DamageClass.Ranged; } } } for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].hostile && Main.projectile[i].damage > 0 && Projectile.Colliding(Projectile.Hitbox, Main.projectile[i].Hitbox) && FargoSoulsUtil.CanDeleteProjectile(Main.projectile[i])) { if (Projectile.owner == Main.myPlayer) { //Vector2 offset = Main.projectile[i].Center - Main.player[Projectile.owner].Center; //Projectile.NewProjectile(Projectile.GetSource_FromThis(), player.Center, Vector2.Zero, ModContent.ProjectileType<Souls.IronParry>(), 0, 0f, Main.myPlayer, offset.X, offset.Y); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Main.projectile[i].Center, Vector2.Zero, ModContent.ProjectileType <Souls.IronParry>(), 0, 0f, Main.myPlayer); } Main.projectile[i].hostile = false; Main.projectile[i].friendly = true; Main.projectile[i].owner = player.whoAmI; // Turn away Main.projectile[i].velocity = Main.projectile[i].DirectionFrom(Projectile.Center) * Main.projectile[i].velocity.Length(); // Don't know if this will help but here it is Main.projectile[i].netUpdate = true; } } if (Projectile.localAI[1] == 0) { Projectile.localAI[0] = Main.rand.Next(10); Projectile.rotation = Main.rand.NextFloat(MathHelper.TwoPi); } Projectile.localAI[1]++; float straightModifier = -0.5f * (float)Math.Cos(Math.PI * 2 / maxTime * Projectile.localAI[1]); float sideModifier = 0.5f * (float)Math.Sin(Math.PI * 2 / maxTime * Projectile.localAI[1]) * player.direction; Vector2 baseVel = new Vector2(Projectile.ai[0], Projectile.ai[1]); Vector2 straightVel = baseVel * straightModifier; Vector2 sideVel = baseVel.RotatedBy(Math.PI / 2) * sideModifier; Projectile.Center = player.Center + baseVel / 2f; Projectile.velocity = straightVel + sideVel; Projectile.rotation += (float)Math.PI / 6.85f * -player.direction; }
public override void AI() { EModeGlobalNPC.championBoss = NPC.whoAmI; if (NPC.localAI[3] == 0) //just spawned { if (!NPC.HasValidTarget) { NPC.TargetClosest(false); } if (NPC.ai[1] == 0) { NPC.Center = Main.player[NPC.target].Center + new Vector2(500 * Math.Sign(NPC.Center.X - Main.player[NPC.target].Center.X), -250); if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + Vector2.UnitY * 1000, Vector2.Zero, ModContent.ProjectileType <EarthChainBlast2>(), 0, 0f, Main.myPlayer, -Vector2.UnitY.ToRotation(), 10); Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center - Vector2.UnitY * 1000, Vector2.Zero, ModContent.ProjectileType <EarthChainBlast2>(), 0, 0f, Main.myPlayer, Vector2.UnitY.ToRotation(), 10); } } if (++NPC.ai[1] > 6 * 9) //nice { NPC.localAI[3] = 1; NPC.ai[1] = 0; NPC.netUpdate = true; if (!Main.dedServ && Main.LocalPlayer.active) { Main.LocalPlayer.GetModPlayer <FargoSoulsPlayer>().Screenshake = 30; } if (Main.netMode != NetmodeID.MultiplayerClient) { const int max = 8; const float baseRotation = MathHelper.TwoPi / max; for (int i = 0; i < max; i++) { float rotation = baseRotation * (i + Main.rand.NextFloat(-0.5f, 0.5f)); Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType <EarthChainBlast2>(), 0, 0f, Main.myPlayer, rotation, 3); } FargoSoulsUtil.NewNPCEasy(NPC.GetSource_FromAI(), NPC.Center, ModContent.NPCType <EarthChampionHand>(), NPC.whoAmI, 0, 0, NPC.whoAmI, 1); FargoSoulsUtil.NewNPCEasy(NPC.GetSource_FromAI(), NPC.Center, ModContent.NPCType <EarthChampionHand>(), NPC.whoAmI, 0, 0, NPC.whoAmI, -1); } } return; } Player player = Main.player[NPC.target]; Vector2 targetPos; if (NPC.HasValidTarget && NPC.Distance(player.Center) < 2500 && player.ZoneUnderworldHeight) { NPC.timeLeft = 600; } NPC.dontTakeDamage = false; NPC.alpha = 0; switch ((int)NPC.ai[0]) { case -1: NPC.localAI[2] = 1; //NPC.dontTakeDamage = true; NPC.ai[1]++; NPC.velocity *= 0.95f; /*if (NPC.ai[1] < 120) * { * targetPos = player.Center; * targetPos.Y -= 375; * if (NPC.Distance(targetPos) > 50) * Movement(targetPos, 0.6f, 24f, true); * } * else*/ if (NPC.ai[1] == 120) //begin healing { SoundEngine.PlaySound(SoundID.NPCDeath10, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { //Projectile.NewProjectile(npc.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType<Projectiles.GlowRing>(), 0, 0f, Main.myPlayer, NPC.whoAmI, -3); if (!Main.dedServ && Main.LocalPlayer.active) { Main.LocalPlayer.GetModPlayer <FargoSoulsPlayer>().Screenshake = 30; } if (Main.netMode != NetmodeID.MultiplayerClient) { const int max = 8; float baseRotation = MathHelper.TwoPi / max * Main.rand.NextFloat(); for (int i = 0; i < max; i++) { float rotation = baseRotation + MathHelper.TwoPi / max * (i + Main.rand.NextFloat(-0.5f, 0.5f)); Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType <EarthChainBlast2>(), 0, 0f, Main.myPlayer, rotation, 3); } } } } else if (NPC.ai[1] > 120) //healing { NPC.velocity *= 0.9f; int heal = (int)(NPC.lifeMax / 2 / 120 * Main.rand.NextFloat(1f, 1.5f)); NPC.life += heal; if (NPC.life > NPC.lifeMax) { NPC.life = NPC.lifeMax; } CombatText.NewText(NPC.Hitbox, CombatText.HealLife, heal); for (int i = 0; i < 5; i++) { int d = Dust.NewDust(NPC.Center, 0, 0, 174, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 8f; } if (NPC.ai[1] > 240) { NPC.ai[0]++; NPC.ai[1] = 0; NPC.ai[2] = 0; NPC.netUpdate = true; } } break; case 0: //float over player if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 2500f || !player.ZoneUnderworldHeight) //despawn code { NPC.TargetClosest(false); if (NPC.timeLeft > 30) { NPC.timeLeft = 30; } NPC.noTileCollide = true; NPC.noGravity = true; NPC.velocity.Y += 1f; return; } else { targetPos = player.Center; targetPos.Y -= 325; if (NPC.Distance(targetPos) > 50) { Movement(targetPos, 0.4f, 16f, true); } } if (NPC.localAI[2] == 0 && NPC.life < NPC.lifeMax / 2) { NPC.ai[0] = -1; NPC.ai[1] = 0; NPC.ai[2] = 0; NPC.ai[3] = 0; for (int i = 0; i < Main.maxNPCs; i++) //find hands, update { if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <EarthChampionHand>() && Main.npc[i].ai[2] == NPC.whoAmI) { Main.npc[i].ai[0] = -1; Main.npc[i].ai[1] = 0; Main.npc[i].localAI[0] = 0; Main.npc[i].localAI[1] = 0; Main.npc[i].netUpdate = true; } } } break; case 1: //fireballs if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 2500f || !player.ZoneUnderworldHeight) //despawn code { NPC.TargetClosest(false); if (NPC.timeLeft > 30) { NPC.timeLeft = 30; } NPC.noTileCollide = true; NPC.noGravity = true; NPC.velocity.Y += 1f; return; } else { targetPos = player.Center; for (int i = 0; i < 22; i++) //collision check above player's head { targetPos.Y -= 16; Tile tile = Framing.GetTileSafely(targetPos); //if solid, stay below it if (tile.HasTile && !tile.IsActuated && Main.tileSolid[tile.TileType] && !Main.tileSolidTop[tile.TileType]) { targetPos.Y += 50 + 16; break; } } if (NPC.Distance(targetPos) > 50) { Movement(targetPos, 0.2f, 12f, true); NPC.position += (targetPos - NPC.Center) / 30; } if (--NPC.ai[2] < 0) { NPC.ai[2] = 75; SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); if (NPC.ai[1] > 10 && Main.netMode != NetmodeID.MultiplayerClient) //shoot spread of fireballs, but not the first time { for (int i = -1; i <= 1; i++) { Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + Vector2.UnitY * 60, (NPC.localAI[2] == 1 ? 12 : 8) * NPC.DirectionTo(player.Center).RotatedBy(MathHelper.ToRadians(8 * i)), ProjectileID.Fireball, FargoSoulsUtil.ScaledProjectileDamage(NPC.damage), 0f, Main.myPlayer); } } } if (++NPC.ai[1] > 480) { NPC.ai[0]++; NPC.ai[1] = 0; NPC.netUpdate = true; } } if (NPC.localAI[2] == 0 && NPC.life < NPC.lifeMax / 2) { NPC.ai[0] = -1; NPC.ai[1] = 0; NPC.ai[2] = 0; NPC.ai[3] = 0; for (int i = 0; i < Main.maxNPCs; i++) //find hands, update { if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <EarthChampionHand>() && Main.npc[i].ai[2] == NPC.whoAmI) { Main.npc[i].ai[0] = -1; Main.npc[i].ai[1] = 0; Main.npc[i].localAI[0] = 0; Main.npc[i].localAI[1] = 0; Main.npc[i].netUpdate = true; } } } break; default: NPC.ai[0] = 0; goto case 0; } }
public override void KillMultiTile(int i, int j, int frameX, int frameY) { Item.NewItem(i * 16, j * 16, 32, 16, ItemType <Items.Placeable.KingTrophy>()); SoundEngine.PlaySound(2, i * 16, j * 16, 27); }
public override void AI() { Vector2?vector78 = null; if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero) { Projectile.velocity = -Vector2.UnitY; } /*if (Main.npc[(int)Projectile.ai[1]].active && Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType<CosmosChampion>()) * { * * } * else * { * Projectile.Kill(); * return; * }*/ if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero) { Projectile.velocity = -Vector2.UnitY; } if (Projectile.localAI[0] == 0f) { SoundEngine.PlaySound(new SoundStyle("Terraria/Sounds/Zombie_104"), Projectile.Center + 3000 * Projectile.velocity); } float num801 = 3f; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= maxTime) { Projectile.Kill(); return; } Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * 3.14159274f / maxTime) * 5f * num801; if (Projectile.scale > num801) { Projectile.scale = num801; } float num804 = Projectile.velocity.ToRotation(); //num804 += Projectile.ai[0]; Projectile.rotation = num804 - 1.57079637f; //float num804 = Main.npc[(int)Projectile.ai[1]].ai[3] - 1.57079637f + Projectile.ai[0]; //if (Projectile.ai[0] != 0f) num804 -= (float)Math.PI; //Projectile.rotation = num804; //num804 += 1.57079637f; Projectile.velocity = num804.ToRotationVector2(); float num805 = 3f; float num806 = (float)Projectile.width; Vector2 samplingPoint = Projectile.Center; if (vector78.HasValue) { samplingPoint = vector78.Value; } float[] array3 = new float[(int)num805]; //Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 3000f, array3); for (int i = 0; i < array3.Length; i++) { array3[i] = 6000f; } float num807 = 0f; int num3; for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1) { num807 += array3[num808]; num3 = num808; } num807 /= num805; float amount = 0.5f; Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); Vector2 vector79 = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f); for (int num809 = 0; num809 < 2; num809 = num3 + 1) { float num810 = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * 1.57079637f; float num811 = (float)Main.rand.NextDouble() * 2f + 2f; Vector2 vector80 = new Vector2((float)Math.Cos((double)num810) * num811, (float)Math.Sin((double)num810) * num811); int num812 = Dust.NewDust(vector79, 0, 0, 244, vector80.X, vector80.Y, 0, default(Color), 1f); Main.dust[num812].noGravity = true; Main.dust[num812].scale = 1.7f; num3 = num809; } if (Main.rand.NextBool(5)) { Vector2 value29 = Projectile.velocity.RotatedBy(1.5707963705062866, default(Vector2)) * ((float)Main.rand.NextDouble() - 0.5f) * (float)Projectile.width; int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 244, 0f, 0f, 100, default(Color), 1.5f); Dust dust = Main.dust[num813]; dust.velocity *= 0.5f; Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); } //DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); //Utils.PlotTileLine(Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], (float)Projectile.width * Projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); Projectile.position -= Projectile.velocity; for (int i = 0; i < 40; i++) { int d = Dust.NewDust(Projectile.position + Projectile.velocity * Main.rand.NextFloat(6000), Projectile.width, Projectile.height, 229, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 6f; } }
public override bool PreAI(NPC npc) { EModeGlobalNPC.eyeBoss = npc.whoAmI; if (FargoSoulsWorld.SwarmActive) { return(true); } void SpawnServants() { if (npc.life <= npc.lifeMax * 0.65 && NPC.CountNPCS(NPCID.ServantofCthulhu) < 9 && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vel = new Vector2(3, 3); for (int i = 0; i < 4; i++) { int n = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.ServantofCthulhu); if (n != Main.maxNPCs) { Main.npc[n].velocity = vel.RotatedBy(Math.PI / 2 * i); if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, n); } } } } } npc.dontTakeDamage = npc.alpha > 50; if (npc.dontTakeDamage) { Lighting.AddLight(npc.Center, 0.75f, 1.35f, 1.5f); } if (ScytheSpawnTimer > 0) { if (ScytheSpawnTimer % (IsInFinalPhase ? 2 : 6) == 0 && Main.netMode != NetmodeID.MultiplayerClient) { if (IsInFinalPhase && !FargoSoulsWorld.MasochistModeReal) { int p = Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType <BloodScythe>(), FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 1f, Main.myPlayer); if (p != Main.maxProjectiles) { Main.projectile[p].timeLeft = 75; } } else { Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Normalize(npc.velocity), ModContent.ProjectileType <BloodScythe>(), FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 1f, Main.myPlayer); } } ScytheSpawnTimer--; } if (npc.ai[0] == 0f && npc.ai[1] == 2f && npc.ai[2] == 0f) { ScytheSpawnTimer = 30; } if (npc.ai[1] == 3f && !IsInFinalPhase) //during dashes in phase 2 { if (FargoSoulsWorld.MasochistModeReal) { ScytheSpawnTimer = 30; SpawnServants(); } if (!ScytheRingIsOnCD) { ScytheRingIsOnCD = true; if (Main.netMode != NetmodeID.MultiplayerClient) { FargoSoulsUtil.XWay(8, npc.GetSource_FromThis(), npc.Center, ModContent.ProjectileType <BloodScythe>(), 1.5f, FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 0); } } } else { ScytheRingIsOnCD = false; //hacky fix for scythe spam during p2 transition } if (npc.life < npc.lifeMax / 2) { if (IsInFinalPhase) //final phase { const float speedModifier = 0.3f; if (npc.HasValidTarget && !Main.dayTime) { if (npc.timeLeft < 300) { npc.timeLeft = 300; } } else //despawn and retarget { npc.TargetClosest(false); npc.velocity.X *= 0.98f; npc.velocity.Y -= npc.velocity.Y > 0 ? 1f : 0.25f; if (npc.timeLeft > 30) { npc.timeLeft = 30; } AITimer = 90; FinalPhaseDashCD = 0; FinalPhaseBerserkDashesComplete = true; FinalPhaseDashHorizSpeedSet = false; FinalPhaseAttackCounter = 0; npc.alpha = 0; const float PI = (float)Math.PI; if (npc.rotation > PI) { npc.rotation -= 2 * PI; } if (npc.rotation < -PI) { npc.rotation += 2 * PI; } float targetRotation = npc.DirectionTo(Main.player[npc.target].Center).ToRotation() - PI / 2; if (targetRotation > PI) { targetRotation -= 2 * PI; } if (targetRotation < -PI) { targetRotation += 2 * PI; } npc.rotation = MathHelper.Lerp(npc.rotation, targetRotation, 0.07f); } if (++AITimer == 1) //teleport to random position { if (Main.netMode != NetmodeID.MultiplayerClient) { npc.Center = Main.player[npc.target].Center; npc.position.X += Main.rand.NextBool() ? -600 : 600; npc.position.Y += Main.rand.NextBool() ? -400 : 400; npc.TargetClosest(false); npc.netUpdate = true; NetSync(npc); } } else if (AITimer < 90) //fade in, moving into position { npc.alpha -= FargoSoulsWorld.MasochistModeReal ? 5 : 4; if (npc.alpha < 0) { npc.alpha = 0; if (FargoSoulsWorld.MasochistModeReal && AITimer < 90) { AITimer = 90; } } const float PI = (float)Math.PI; if (npc.rotation > PI) { npc.rotation -= 2 * PI; } if (npc.rotation < -PI) { npc.rotation += 2 * PI; } float targetRotation = npc.DirectionTo(Main.player[npc.target].Center).ToRotation() - PI / 2; if (targetRotation > PI) { targetRotation -= 2 * PI; } if (targetRotation < -PI) { targetRotation += 2 * PI; } npc.rotation = MathHelper.Lerp(npc.rotation, targetRotation, 0.07f); for (int i = 0; i < 3; i++) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].noLight = true; Main.dust[d].velocity *= 4f; } Vector2 target = Main.player[npc.target].Center; target.X += npc.Center.X < target.X ? -600 : 600; target.Y += npc.Center.Y < target.Y ? -400 : 400; if (npc.Center.X < target.X) { npc.velocity.X += speedModifier; if (npc.velocity.X < 0) { npc.velocity.X += speedModifier * 2; } } else { npc.velocity.X -= speedModifier; if (npc.velocity.X > 0) { npc.velocity.X -= speedModifier * 2; } } if (npc.Center.Y < target.Y) { npc.velocity.Y += speedModifier; if (npc.velocity.Y < 0) { npc.velocity.Y += speedModifier * 2; } } else { npc.velocity.Y -= speedModifier; if (npc.velocity.Y > 0) { npc.velocity.Y -= speedModifier * 2; } } if (Math.Abs(npc.velocity.X) > 24) { npc.velocity.X = 24 * Math.Sign(npc.velocity.X); } if (Math.Abs(npc.velocity.Y) > 24) { npc.velocity.Y = 24 * Math.Sign(npc.velocity.Y); } } else if (!FinalPhaseBerserkDashesComplete) //berserk dashing phase { AITimer = 90; const float xSpeed = 18f; const float ySpeed = 40f; if (++FinalPhaseDashCD == 1) { SoundEngine.PlaySound(SoundID.ForceRoarPitched, Main.player[npc.target].Center); if (!FinalPhaseDashHorizSpeedSet) //only set this on the first dash of each set { FinalPhaseDashHorizSpeedSet = true; npc.velocity.X = npc.Center.X < Main.player[npc.target].Center.X ? xSpeed : -xSpeed; } npc.velocity.Y = npc.Center.Y < Main.player[npc.target].Center.Y ? ySpeed : -ySpeed; //alternate this every dash ScytheSpawnTimer = 30; if (FargoSoulsWorld.MasochistModeReal) { SpawnServants(); } if (Main.netMode != NetmodeID.MultiplayerClient) { FargoSoulsUtil.XWay(8, npc.GetSource_FromThis(), npc.Center, ModContent.ProjectileType <BloodScythe>(), 1f, FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 0); } npc.netUpdate = true; } else if (FinalPhaseDashCD > 20) { FinalPhaseDashCD = 0; } if (++FinalPhaseDashStageDuration > 600 * 3 / xSpeed + 5) //proceed { ScytheSpawnTimer = 0; FinalPhaseDashStageDuration = 0; FinalPhaseBerserkDashesComplete = true; if (!FargoSoulsWorld.MasochistModeReal) { FinalPhaseAttackCounter++; } npc.velocity *= 0.75f; npc.netUpdate = true; } const float PI = (float)Math.PI; npc.rotation = npc.velocity.ToRotation() - PI / 2; if (npc.rotation > PI) { npc.rotation -= 2 * PI; } if (npc.rotation < -PI) { npc.rotation += 2 * PI; } } else { bool mustRest = FinalPhaseAttackCounter >= 5; const int restingTime = 240; int threshold = 180; if (mustRest) { threshold += restingTime; } if (mustRest && AITimer < restingTime + 90) { if (AITimer == 91) { npc.velocity = npc.DirectionTo(Main.player[npc.target].Center) * npc.velocity.Length() * 0.75f; } npc.velocity.X *= 0.98f; if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 300) { npc.velocity.X *= 0.9f; } bool floatUp = Collision.SolidCollision(npc.position, npc.width, npc.height); if (!floatUp && npc.Bottom.X > 0 && npc.Bottom.X < Main.maxTilesX * 16 && npc.Bottom.Y > 0 && npc.Bottom.Y < Main.maxTilesY * 16) { Tile tile = Framing.GetTileSafely(npc.Bottom); if (tile != null && tile.HasUnactuatedTile) { floatUp = Main.tileSolid[tile.TileType]; } } if (floatUp) { npc.velocity.X *= 0.95f; npc.velocity.Y -= speedModifier; if (npc.velocity.Y > 0) { npc.velocity.Y = 0; } if (Math.Abs(npc.velocity.Y) > 24) { npc.velocity.Y = 24 * Math.Sign(npc.velocity.Y); } } else { npc.velocity.Y += speedModifier; if (npc.velocity.Y < 0) { npc.velocity.Y += speedModifier * 2; } if (npc.velocity.Y > 15) { npc.velocity.Y = 15; } } } else { npc.alpha += FargoSoulsWorld.MasochistModeReal ? 16 : 4; if (npc.alpha > 255) { npc.alpha = 255; if (FargoSoulsWorld.MasochistModeReal && AITimer < threshold) { AITimer = threshold; } } if (mustRest) { npc.velocity.Y -= speedModifier * 0.5f; if (npc.velocity.Y > 0) { npc.velocity.Y = 0; } if (Math.Abs(npc.velocity.Y) > 24) { npc.velocity.Y = 24 * Math.Sign(npc.velocity.Y); } } else { npc.velocity *= 0.98f; } } const float PI = (float)Math.PI; float targetRotation = MathHelper.WrapAngle(npc.DirectionTo(Main.player[npc.target].Center).ToRotation() - PI / 2); npc.rotation = MathHelper.WrapAngle(MathHelper.Lerp(npc.rotation, targetRotation, 0.07f)); if (npc.alpha > 0) { for (int i = 0; i < 3; i++) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].noLight = true; Main.dust[d].velocity *= 4f; } } if (AITimer > threshold) //reset { AITimer = 0; FinalPhaseDashCD = 0; FinalPhaseBerserkDashesComplete = false; FinalPhaseDashHorizSpeedSet = false; if (mustRest) { FinalPhaseAttackCounter = 0; } npc.velocity = Vector2.Zero; npc.netUpdate = true; } } if (npc.netUpdate) { if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI); NetSync(npc); } npc.netUpdate = false; } return(false); } else if (!IsInFinalPhase && npc.life <= npc.lifeMax * 0.1) //go into final phase { npc.velocity *= 0.98f; npc.alpha += 4; for (int i = 0; i < 3; i++) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].noLight = true; Main.dust[d].velocity *= 4f; } if (npc.alpha > 255) { npc.alpha = 255; IsInFinalPhase = true; SoundEngine.PlaySound(SoundID.Roar, npc.HasValidTarget ? Main.player[npc.target].Center : npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(npc.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType <GlowRing>(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.type); } } return(false); } else if (npc.ai[0] == 3 && (npc.ai[1] == 0 || npc.ai[1] == 5)) { if (npc.ai[2] < 2) { npc.ai[2]--; npc.alpha += 4; for (int i = 0; i < 3; i++) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].noLight = true; Main.dust[d].velocity *= 4f; } if (npc.alpha > 255) { npc.alpha = 255; if (Main.netMode != NetmodeID.MultiplayerClient && npc.HasPlayerTarget) { npc.ai[2] = 60; npc.ai[1] = 5f; Vector2 distance = Main.player[npc.target].Center - npc.Center; if (Math.Abs(distance.X) > 1200) { distance.X = 1200 * Math.Sign(distance.X); } else if (Math.Abs(distance.X) < 600) { distance.X = 600 * Math.Sign(distance.X); } if (distance.Y > 0) //always ensure eoc teleports above player { distance.Y *= -1; } if (Math.Abs(distance.Y) > 450) { distance.Y = 450 * Math.Sign(distance.Y); } if (Math.Abs(distance.Y) < 150) { distance.Y = 150 * Math.Sign(distance.Y); } npc.Center = Main.player[npc.target].Center + distance; npc.netUpdate = true; } } } else { npc.alpha -= 4; if (npc.alpha < 0) { npc.alpha = 0; } else { npc.ai[2]--; npc.position -= npc.velocity / 2; for (int i = 0; i < 3; i++) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].noLight = true; Main.dust[d].velocity *= 4f; } } } } /*if (++Timer > 600) * { * Timer = 0; * if (npc.HasValidTarget) * { * Player player = Main.player[npc.target]; * SoundEngine.PlaySound(SoundID.Item9104, player.Center); * if (Main.netMode != NetmodeID.MultiplayerClient) * { * Vector2 spawnPos = player.Center; * int direction; * if (player.velocity.X == 0f) * direction = player.direction; * else * direction = Math.Sign(player.velocity.X); * spawnPos.X += 600 * direction; * spawnPos.Y -= 600; * Vector2 speed = Vector2.UnitY; * for (int i = 0; i < 30; i++) * { * Projectile.NewProjectile(npc.GetSource_FromThis(), spawnPos, speed, ModContent.ProjectileType<BloodScythe>(), FargoSoulsUtil.ScaledProjectileDamage(npc.damage), 1f, Main.myPlayer); * spawnPos.X += 72 * direction; * speed.Y += 0.15f; * } * } * } * }*/ } else { npc.alpha = 0; npc.dontTakeDamage = false; } // Drop summon EModeUtils.DropSummon(npc, "SuspiciousEye", NPC.downedBoss1, ref DroppedSummon); return(true); }
private void BackClick(UIMouseEvent evt, UIElement listeningElement) { SoundEngine.PlaySound(SoundID.MenuClose); Main.menuMode = Interface.modSourcesID; }