public static void BeingAttacked() { foreach (Player target in Sky_boss.targets) { if (time++ % elapsed * 2 == 0 && time != 0) { if (target != null) { if (npc.Distance(target.Center) < range) { switch (type) { case Melee: target.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 10, 0); break; case Range: target.velocity += ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(target.Center, npc.Center), 0.5f); VelClamp(ref target.velocity, -2f, 2f, out target.velocity); break; case Magic: if (target.statMana > 5) { target.statMana -= 5; target.manaRegenDelay = 30; } break; } } } } } }
/// <summary> /// This function deals damage within an area to the player when an explosion happens /// </summary> /// <param name="DamageRadius"> Determines the radius of the damage projectiles explosion </param> /// <param name="DamagePosition"> Determines the center point of the damage projectiles explosion </param> /// <param name="Damage"> Stores the damage projectiles damage amount </param> /// <param name="npc"> Stores the npc who spawned the projectile </param> public static void ExplosionDamageEnemy(int DamageRadius, Vector2 DamagePosition, int Damage, int npc) { foreach (Player player in Main.player) { if (player == null || player.whoAmI == 255 || !player.active) { return; } if (player.EE().BlastShielding&& player.EE().BlastShieldingActive) { continue; } float dist = Vector2.Distance(player.Center, DamagePosition); int dir = (dist > 0) ? 1 : -1; if (dist / 16f <= DamageRadius && Main.netMode == NetmodeID.SinglePlayer) { player.Hurt(PlayerDeathReason.ByNPC(npc), Damage, dir); player.hurtCooldowns[0] += 15; } else if (Main.netMode != NetmodeID.MultiplayerClient && dist / 16f <= DamageRadius) { NetMessage.SendPlayerHurt(Main.myPlayer, PlayerDeathReason.ByNPC(npc), Damage, dir, false, pvp: true, 0); } } }
public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { if (target.active && !target.dead && !target.ghost) { Main.NewText(":echdeath:", Color.Red); target.ResetEffects(); target.ghost = true; target.KillMe(PlayerDeathReason.ByNPC(npc.whoAmI), npc.damage, 0); for (int i = 0; i < 100; i++) { CombatText.NewText(target.Hitbox, Color.Red, Main.rand.Next(npc.damage), true); } } }
public override void Kill(int timeLeft) { MMod.explosionEffect(projectile, 1f); Player target = Main.player[(int)projectile.ai[0]]; float dX = target.position.X + (float)target.width * 0.5f - projectile.Center.X; float dY = target.position.Y - projectile.Center.Y; float distance = (float)System.Math.Sqrt((double)(dX * dX + dY * dY)); if (distance < 50) { for (int i = 0; i < Main.npc.Length - 1; i++) { NPC berramyr = Main.npc[i]; if (berramyr.type == mod.NPCType("Berramyr")) { target.Hurt(PlayerDeathReason.ByNPC(i), 10, projectile.direction); } } } }
public virtual void ExplosionDamage() { float radius = 15f; foreach (NPC npcID in Main.npc) { float dist = Vector2.Distance(npcID.Center, npc.Center); if (dist / 16f <= radius && !npcID.boss) { int dir = (dist > 0) ? 1 : -1; npcID.StrikeNPC(120, 10f, dir, true); } } foreach (Player player in Main.player) { if (player == null || player.whoAmI == 255 || !player.active) { return; } //if (!CanHitPlayer(player)) continue; if (player.EE().BlastShielding&& player.EE().BlastShieldingActive) { continue; } float dist = Vector2.Distance(player.Center, npc.Center); int dir = (dist > 0) ? 1 : -1; if (dist / 16f <= radius) { //Main.NewText("Hit"); player.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 120, dir); player.hurtCooldowns[0] += 15; } if (Main.netMode != 0) { NetMessage.SendPlayerHurt(player.whoAmI, PlayerDeathReason.ByNPC(npc.whoAmI), 120, dir, false, pvp: false, 0); } } }
public static void BeingAttacked() { foreach (Player target in Main.player.Where(t => t.Distance(npc.Center) < range)) { if (time++ % elapsed * 2 == 0 && time != 0) { if (target != null) { if (npc.Distance(target.Center) < range) { switch (type) { case Melee: target.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 10, 0); NetMessage.SendData(MessageID.HurtPlayer, -1, -1, null, target.whoAmI); break; case Range: target.velocity += ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(target.Center, npc.Center), 0.5f); VelClamp(ref target.velocity, -2f, 2f, out target.velocity); break; case Magic: if (target.statMana > 5) { target.statMana -= 5; target.manaRegenDelay = 180; NetMessage.SendData(MessageID.PlayerMana, -1, -1, null, target.whoAmI, target.statMana); } break; } } } } } }
public override void AI() { npc.timeLeft = 60; if (!npc.HasValidTarget) { npc.TargetClosest(false); } if (!(ceilingProj >= 0 && ceilingProj < Main.maxProjectiles && Main.projectile[ceilingProj].active && Main.projectile[ceilingProj].type == ModContent.ProjectileType <CeilingProj>())) { if (Main.netMode != NetmodeID.MultiplayerClient) { ceilingProj = Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <CeilingProj>(), 0, 0f, Main.myPlayer, 0f, npc.whoAmI); } npc.netUpdate = true; } if (npc.localAI[3] == 0) { npc.localAI[3] = 1; if (Main.netMode != NetmodeID.MultiplayerClient) { int n = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <CeilingOfMoonLordEye>(), npc.whoAmI, npc.whoAmI, 1); if (n != Main.maxNPCs && Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, number: n); } npc.ai[0] = n; n = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <CeilingOfMoonLordEye>(), npc.whoAmI, npc.whoAmI, -1); if (n != Main.maxNPCs && Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, number: n); } npc.ai[1] = n; n = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <CeilingOfMoonLordFace>(), npc.whoAmI, npc.whoAmI); if (n != Main.maxNPCs && Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, number: n); } npc.ai[2] = n; } npc.netUpdate = true; } if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && !Main.LocalPlayer.ghost) { Main.LocalPlayer.AddBuff(ModContent.BuffType <Moonified>(), 2); if (Main.LocalPlayer.Center.Y < npc.Center.Y - 32 || //teleport and hurt if player is EVER above boss or too far to sides Main.LocalPlayer.Center.Y > npc.Center.Y + 1500 || Math.Abs(Main.LocalPlayer.Center.X - npc.Center.X) > 1500) { Vector2 teleportPos = npc.Center; teleportPos.Y += 250; bool hurt = Main.LocalPlayer.Center.Y < npc.Center.Y; for (int i = 0; i < 50; i++) { int d = Dust.NewDust(Main.player[Main.myPlayer].position, Main.player[Main.myPlayer].width, Main.player[Main.myPlayer].height, 229, 0f, 0f, 0, default(Color), 2.5f); Main.dust[d].noGravity = true; Main.dust[d].noLight = true; Main.dust[d].velocity *= 9f; } Main.LocalPlayer.Teleport(teleportPos); NetMessage.SendData(MessageID.Teleport, -1, -1, null, 0, Main.LocalPlayer.whoAmI, teleportPos.X, teleportPos.Y, 1); Main.LocalPlayer.velocity = Vector2.Zero; if (hurt) { Main.LocalPlayer.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), npc.damage, 1); Main.LocalPlayer.immune = false; Main.LocalPlayer.immuneTime = 0; Main.LocalPlayer.hurtCooldowns[0] = 0; Main.LocalPlayer.hurtCooldowns[1] = 0; } for (int i = 0; i < 50; i++) { int d = Dust.NewDust(Main.player[Main.myPlayer].position, Main.player[Main.myPlayer].width, Main.player[Main.myPlayer].height, 229, 0f, 0f, 0, default(Color), 2.5f); Main.dust[d].noGravity = true; Main.dust[d].noLight = true; Main.dust[d].velocity *= 9f; } } if (Main.LocalPlayer.ZoneUnderworldHeight) //kill when reached underworld { Main.LocalPlayer.KillMe(PlayerDeathReason.ByOther(12), 9999, 0, false); } } if (npc.position.Y > Main.maxTilesY * 16) //despawn upon exiting the bottom of world { npc.active = false; } npc.velocity.Y = 1.5f; if (npc.life < npc.lifeMax * 0.75) { npc.velocity.Y += 0.25f; } if (npc.life < npc.lifeMax * 0.5) { npc.velocity.Y += 0.4f; } if (npc.life < npc.lifeMax * 0.25) { npc.velocity.Y += 0.5f; } if (npc.life < npc.lifeMax * 0.1) { npc.velocity.Y += 0.6f; } if (npc.life < npc.lifeMax * 0.66 && Main.expertMode) { npc.velocity.Y += 0.3f; } if (npc.life < npc.lifeMax * 0.33 && Main.expertMode) { npc.velocity.Y += 0.3f; } if (npc.life < npc.lifeMax * 0.05 && Main.expertMode) { npc.velocity.Y += 0.6f; } if (npc.life < npc.lifeMax * 0.035 && Main.expertMode) { npc.velocity.Y += 0.6f; } if (npc.life < npc.lifeMax * 0.025 && Main.expertMode) { npc.velocity.Y += 0.6f; } if (Main.expertMode) { npc.velocity.Y = npc.velocity.Y * 1.35f + 0.35f; } if (Math.Abs(Main.player[npc.target].Center.X - npc.Center.X) > 150) { npc.velocity.X = 2 * npc.velocity.Y * Math.Sign(Main.player[npc.target].Center.X - npc.Center.X); } if (npc.life < npc.lifeMax / 2) { npc.localAI[0]++; } if (++npc.localAI[0] > 300) { npc.localAI[0] = 0; if (Main.netMode != NetmodeID.MultiplayerClient) //spray homing eyes { for (int i = 0; i < 6; i++) { Projectile.NewProjectile(npc.Center + Main.rand.NextVector2Square(0f, npc.width), Vector2.UnitX.RotatedByRandom(Math.PI) * 6f, ProjectileID.PhantasmalEye, npc.damage / 7, 0f, Main.myPlayer); } } } }
public override void AI() { if (!npc.HasValidTarget) { //npc.ai[0] = 0; npc.TargetClosest(); /*if (!npc.HasValidTarget) * { * npc.active = false; * return; * }*/ } //npc.life = npc.lifeMax; npc.damage = npc.defDamage; npc.defense = npc.defDefense; npc.ai[0] += 0.05f; if (npc.HasValidTarget) { Player player = Main.player[npc.target]; npc.direction = npc.spriteDirection = npc.Center.X < player.Center.X ? 1 : -1; if (npc.ai[1] == 1) { npc.position += (player.position - player.oldPosition) * 0.25f; } npc.velocity = npc.DirectionTo(player.Center) * npc.ai[0]; if (npc.velocity.Length() > npc.Distance(player.Center)) { npc.Center = player.Center; } if (npc.timeLeft < 600) { npc.timeLeft = 600; } } else { if (npc.timeLeft > 60) { npc.timeLeft = 60; } } npc.scale = 1f + npc.ai[0] / 4f; if (Main.netMode != NetmodeID.MultiplayerClient) { int fullSize = (int)(40 * npc.scale); if (npc.ai[1] == 1) { for (int i = -fullSize / 2; i <= fullSize / 2; i += 8) { for (int j = -fullSize / 2; j <= fullSize / 2; j += 8) { int tileX = (int)(npc.Center.X + i) / 16; int tileY = (int)(npc.Center.Y + j) / 16; //out of bounds checks if (tileX > -1 && tileX < Main.maxTilesX && tileY > -1 && tileY < Main.maxTilesY) { Tile tile = Framing.GetTileSafely(tileX, tileY); if (tile.type != 0 || tile.wall != 0) { WorldGen.KillTile(tileX, tileY, noItem: true); WorldGen.KillWall(tileX, tileY); if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, tileX, tileY); } } } } } } for (int i = 0; i < Main.maxNPCs; i++) { if (Main.npc[i].active && Main.npc[i].type != npc.type && npc.Distance(Main.npc[i].Center) < fullSize / 2) { if (Main.netMode == NetmodeID.SinglePlayer) { Main.NewText(":echdeath:", Color.Red); } else if (Main.netMode == NetmodeID.Server) { NetMessage.BroadcastChatMessage(NetworkText.FromLiteral(":echdeath:"), Color.Red); } Main.npc[i].StrikeNPC(npc.damage, 99f, npc.Center.X < Main.npc[i].Center.X ? 1 : -1); for (int j = 0; j < 100; j++) { CombatText.NewText(Main.npc[i].Hitbox, Color.Red, Main.rand.Next(npc.damage), true); } } } } if (Main.LocalPlayer.active && !Main.LocalPlayer.dead && !Main.LocalPlayer.ghost && npc.Hitbox.Intersects(Main.LocalPlayer.Hitbox)) { Main.NewText(":echdeath:", Color.Red); Main.LocalPlayer.ResetEffects(); Main.LocalPlayer.ghost = true; Main.LocalPlayer.KillMe(PlayerDeathReason.ByNPC(npc.whoAmI), npc.damage, 0); for (int i = 0; i < 100; i++) { CombatText.NewText(Main.LocalPlayer.Hitbox, Color.Red, Main.rand.Next(npc.damage), true); } } if (npc.ai[1] == 1) { if (!Main.dedServ && Main.LocalPlayer.active) { Main.LocalPlayer.GetModPlayer <FargoPlayer>().Screenshake = 2; } if (npc.localAI[0] == 0) { Main.NewText("Echdeath has enraged.", Color.DarkRed); npc.localAI[0] = 1; for (int i = 0; i < npc.buffImmune.Length; i++) { npc.buffImmune[i] = true; } } while (npc.buffType[0] != 0) { npc.DelBuff(0); } if (npc.ai[2] == 0) //force life back to max until it works { if (npc.life == npc.lifeMax) { npc.ai[2] = 1; } npc.life = npc.lifeMax; } } else { if (npc.ai[0] > 30) { npc.ai[0] = 30; } } }
public override void AI() { fuckingRun = Friends.Count == 0; if (!Base()) { return; } // If there IS a target and a friend, then target a position 200 pixels away from the player. Vector2 goTo = Target.Center + Vector2.UnitY * -300; // Find all NPCs of my type and order them by whoAmI. List <NPC> likeMe = Main.npc.Where(x => x.active && x.type == npc.type && x.ai[1] == npc.ai[1]).OrderBy(x => x.whoAmI).ToList(); float myIndex = likeMe.IndexOf(npc); // Find how far on a circle this NPC should be rotated by, in proportion to its index in the list. float rotatedBy = MathHelper.Lerp(0, MathHelper.TwoPi, myIndex / likeMe.Count); // Pivot around the Target for where this NPC should go. goTo = goTo.RotatedBy(rotatedBy, Target.Center); // Now go there! npc.velocity = npc.GoTo(goTo, 0.3f); npc.velocity = Vector2.Clamp(npc.velocity, Vector2.One * -6, Vector2.One * 6); // Also set up the "arcs," which are just Collision checks. If the player is colliding with a line, hurt him. foreach (var friend in Friends) { // Is target colliding with a line? bool hittingLine = Collision.CheckAABBvLineCollision( Target.position, new Vector2(Target.Hitbox.Width, Target.Hitbox.Height), npc.Center, friend.Center); if (hittingLine && Target is Player tPlayer) // If it's a yes and the target is a player, run that player's hurt code. { tPlayer.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), npc.damage - 10, 0); tPlayer.immune = true; } else if (hittingLine && Target is NPC tNPC && tNPC.immune[255] <= 0) // Otherwise (and if yes), run the NPC's code. { tNPC.StrikeNPC(npc.damage, 2f, 0); tNPC.immune[255] = 15; } // Zoop dustSpawnPos += Main.rand.NextFloat() / 20f; dustSpawnPos %= 1f; Vector2 dir = (friend.Center - npc.Center).SafeNormalize(Vector2.Zero) * 38; Dust dust = Dust.NewDustPerfect( Vector2.Lerp(npc.Center + dir, friend.Center - dir, dustSpawnPos), DustType <DracocideDust>()); dust.noLight = true; dust.velocity = Vector2.Zero; dust.customData = -20; dust.fadeIn = 10; } // Set the NPC's rotation between its other friends. if (Friends.Count == 1) // if only one, just face it. { npc.rotation = (Friends[0].Center - npc.Center).ToRotation() + MathHelper.PiOver2; } else if (myIndex == 1) { npc.rotation = MathHelper.Lerp(Friends[0].rotation, Friends[1].rotation, 0.5f) + MathHelper.Pi; } else // otherwise, average. { npc.rotation = Friends.Average(x => (x.Center - npc.Center).ToRotation()) + MathHelper.PiOver2; } }
private void floatAround(Vector2 moveTo, Player p) { float fOne = (float)Main.rand.Next(-100, 100); float fTwo = (float)Main.rand.Next(-100, 100); float pX = p.Center.X - npc.Center.X; float pY = p.Center.Y - npc.Center.Y; float pDistance = (float)System.Math.Sqrt((double)(pX * pX + pY * pY)); if (portCoolDown > 0) { portCoolDown--; } if (pDistance < 50 && portCoolDown == 0) { MMod.explosionEffect(npc, 4f); for (int i = 0; i < 255; i++) { Player players = Main.player[i]; float dX = players.Center.X - npc.Center.X; float dY = players.Center.Y - npc.Center.Y; float playersDistance = (float)System.Math.Sqrt((double)dX * dX + dY * dY); if (playersDistance < 50) { p.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 30, p.direction); } } int[] posNeg = { 1, -1 }; float sX = posNeg[Main.rand.Next(0, 1)]; float sY = posNeg[Main.rand.Next(0, 1)]; float tDistance = 400f; npc.position.X = p.Center.X + (tDistance * sX) + fOne; npc.position.Y = p.Center.Y + (tDistance * sY) + fTwo; didOnce = 0; portCoolDown = 180; } float moveToX = moveTo.X - npc.Center.X + fOne; float moveToY = moveTo.Y - npc.Center.Y + fTwo; float distance = (float)System.Math.Sqrt((double)(moveToX * moveToX + moveToY * moveToY)); float speed = 5f; if (pDistance > 500) { speed = 15f; } distance = speed / distance; moveToX *= distance; moveToY *= distance; if (pDistance > 500) { pX += fOne * 2; pY += fTwo * 2; pX *= distance; pY *= distance; } if (didOnce == 0 || pDistance > 500) { npc.velocity.X = moveToX; npc.velocity.Y = moveToY; if (pDistance > 500) { npc.velocity.X = pX; npc.velocity.Y = pY; } didOnce = 1; } if (mode == 4) { flammenWheel(p); } }
public override void AI() { if (initialize) { hoverOffset = new Vector2(0, -200f); initialize = false; } // Run base AI and if not active do not execute glyph specific AI base.AI(); if (!isActive) { DeactivateShaders(); return; } // Toggle burn periodically if (aiPhase % burnInterval == 0) { burnOn = !burnOn; move = !burnOn; hover = burnOn; if (Main.netMode != NetmodeID.Server) { // Toggle shaders if (burnOn) { npc.velocity = Vector2.Zero; ActivateShaders(); } else { DeactivateShaders(); } } } // Update shaders if (Main.netMode != NetmodeID.Server && Filters.Scene["GlyphBurningGlow"].IsActive() && Filters.Scene["GlyphBurningDistort"].IsActive()) { float progress = (float)filterTimer; float buildup = (float)filterTimer / (float)filterBuildupTime; if (buildup > 1f) { buildup = 1f; } // Intensity is the buildup of the overexposure glow, progress is just time Filters.Scene["GlyphBurningGlow"].GetShader().UseIntensity(buildup).UseProgress(progress); Filters.Scene["GlyphBurningDistort"].GetShader().UseIntensity(buildup).UseProgress(progress); } // If burning if (burnOn) { if (aiPhase % 40 == 0) { Main.PlaySound(SoundID.Item82, npc.Center); } // Raycast each player and deal dmg if hit foreach (Player player in players) { Vector2 dir = player.Center - npc.Center; if (dir.Length() < burnDistance) { dir.Normalize(); bool reached = false; bool hitWall = false; Vector2 curPos = npc.Center + dir * 25f; // Basically check every tile between npc and player(s) while (!reached && !hitWall) { Tile tile = Main.tile[(int)curPos.X / 16, (int)curPos.Y / 16]; if (tile != null && Main.tileSolid[tile.type] && tile.collisionType == 1) { hitWall = true; // Wall hit } if ((npc.Center - curPos).Length() >= (npc.Center - player.Center).Length()) { reached = true; // Player hit } curPos += dir * 0.5f; } // Deal damage if player is hit if (reached) { int direction = npc.Center.X > player.Center.X ? -1 : 1; player.Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), burnDamage, direction); } } } } if (move) { MoveTowards(npc, boss.Center + hoverOffset, targetingSpeed, targetingTurnResistance); } if (hover) { npc.velocity -= lastHoverVelocity; float vel = (float)Math.Cos(aiPhase / 180f * Math.PI); lastHoverVelocity = new Vector2(Main.rand.NextFloat(-0.3f, 0.3f), vel * 0.5f); npc.velocity += lastHoverVelocity; } filterTimer++; }