public override void NPCLoot() { ArchaeaWorld modWorld = mod.GetModWorld <ArchaeaWorld>(); modWorld.MagnoDefeated = true; Item.NewItem(lootPos, ItemID.Heart, 6, false, 0, false, false); if (Main.expertMode) { npc.DropBossBags(); } for (int k = 0; k < 2; k++) { Item.NewItem(lootPos, mod.ItemType("magno_fragment"), 8 + Main.rand.Next(2, 6), false, 0, false, false); } int choice = Main.rand.Next(8); int item = 0; switch (choice) { case 0: item = mod.ItemType("magno_trophy"); break; } Item.NewItem(lootPos, item, 1, false, 0, true, false); }
public static Vector2 FindGround(NPC npc, Rectangle bounds) { var vector = FindEmptyRegion(npc, bounds); if (vector != Vector2.Zero) { int i = (int)vector.X / 16; int j = (int)(vector.Y + npc.height - 8) / 16; if (!ArchaeaWorld.Inbounds(i, j)) { return(Vector2.Zero); } int max = npc.width / 16; int move = 0; Tile ground = Main.tile[i + (npc.width / 16 / 2), j + move]; while (NoSolidTileCollision(ground)) { move++; ground = Main.tile[i + (npc.width / 16 / 2), j + move]; } vector.Y += move * 16 - 16; return(vector); } else { return(Vector2.Zero); } }
public static bool TargetBasedMove(NPC npc, Player target, bool playerRange = false) { int width = Main.screenWidth - 100; int height = Main.screenHeight - 100; Vector2 old = npc.position; Vector2 vector; if (target == null) { return(false); } vector = FindGround(npc, new Rectangle((int)target.position.X - width / 2, (int)target.position.Y - height / 2, width, height)); if (!ArchaeaWorld.Inbounds((int)vector.X / 16, (int)vector.Y / 16)) { return(false); } if (vector != Vector2.Zero) { npc.position = vector; } if (old != npc.position) { return(true); } return(false); }
public override void UpdateBiomes() { ArchaeaWorld modWorld = mod.GetModWorld <ArchaeaWorld>(); MagnoBiome = modWorld.MagnoBiome; SkyFort = modWorld.SkyFort; SkyPortal = modWorld.SkyPortal; }
public override bool PreDraw(SpriteBatch s, Color lightColor) { Player owner = Main.player[projectile.owner]; Vector2 OwnerPos = new Vector2(owner.position.X + owner.width / 2, owner.position.Y + owner.height / 2); Vector2 ProjPos = new Vector2(projectile.position.X + projectile.width / 2, projectile.position.Y + projectile.height / 2); float targetrotation = (float)Math.Atan2((ProjPos.Y - OwnerPos.Y), (ProjPos.X - OwnerPos.X)); ArchaeaWorld.DrawChain(OwnerPos, ProjPos, texture, s); return(true); }
public override bool CanKillTile(int i, int j, ref bool blockDamaged) { ArchaeaWorld modWorld = mod.GetModWorld <ArchaeaWorld>(); if (modWorld.MagnoDefeated) { return(true); } else { return(false); } }
public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged) { ArchaeaWorld modWorld = mod.GetModWorld <ArchaeaWorld>(); Tile tile = Main.tile[i, j]; if ((type == mod.TileType <m_stone>() || type == mod.TileType <m_ore>() || type == mod.TileType <m_dirt>()) && (Main.tile[i, j - 1].type == mod.TileType <c_crystalsmall>() || Main.tile[i, j - 1].type == mod.TileType <c_crystal2x1>() || Main.tile[i, j - 1].type == mod.TileType <c_crystal2x2>() || Main.tile[i + 1, j].type == mod.TileType <c_crystalwall>() || Main.tile[i - 1, j].type == mod.TileType <c_crystalwall>() || Main.tile[i, j - 1].type == mod.TileType <m_totem>())) { return(false); } else { return(true); } }
private bool canSee() { Vector2 line; for (float k = 0; k < npc.Distance(target().position); k += 0.5f) { line = npc.Center + ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(npc, target()), k); int i = (int)line.X / 16; int j = (int)line.Y / 16; if (ArchaeaWorld.Inbounds(i, j)) { Tile tile = Main.tile[i, j]; if (tile.active() && Main.tileSolid[tile.type]) { return(false); } } } return(true); }
public static Vector2 FindAny(NPC npc, Player target, bool findGround = true, int range = 400) { int x = 0, y = 0; x = Main.rand.Next((int)target.Center.X - range, (int)target.Center.X + range); y = Main.rand.Next((int)target.Center.Y - (int)(range * 0.67f), (int)target.Center.Y + (int)(range * 0.67f)); x = (x - (x % 16)) / 16; y = (y - (y % 16)) / 16; if (!ArchaeaWorld.Inbounds(x, y)) { return(Vector2.Zero); } if (findGround) { if (!Main.tile[x, y + npc.height / 16 + 1].active() || !Main.tileSolid[Main.tile[x, y + npc.height / 16 + 1].type] || !Main.tileSolid[Main.tile[x + 1, y + npc.height / 16 + 1].type] || Main.tile[x, y + (npc.height - 4) / 16].active()) { return(Vector2.Zero); } } return(new Vector2(x * 16, y * 16)); }
public static Vector2 FindGround(Player player, Rectangle bounds) { var vector = FindEmptyRegion(player, bounds); for (int k = 0; k < 5; k++) { int i = (int)vector.X / 16; int j = (int)(vector.Y + player.height + 8) / 16; if (!ArchaeaWorld.Inbounds(i, j)) { continue; } int count = 0; int max = player.width / 16; for (int l = 0; l < player.width / 16; l++) { Tile ground = Main.tile[i + l, j + 1]; if (ground.active() && Main.tileSolid[ground.type]) { count++; } } while (vector.Y + player.height < j * 16) { vector.Y++; } if (Collision.SolidCollision(vector, player.width - 4, player.height - 4)) { return(Vector2.Zero); } if (count == max) { return(vector); } } return(Vector2.Zero); }
public override void AI() { if (!init) { pathing = 1; int i = (int)npc.position.X / 16; int j = (int)npc.position.Y / 16; if (ArchaeaWorld.Inbounds(i, j) && Main.tile[i, j].wall != ArchaeaWorld.skyBrickWall) { newPosition = ArchaeaNPC.FindAny(npc, target(), true, 800); if (newPosition != Vector2.Zero) { npc.netUpdate = true; if (Main.netMode == 0) { npc.position = newPosition; } } else { return; } } init = true; } if (!ArchaeaWorld.Inbounds((int)npc.position.X / 16, (int)npc.position.Y / 16)) { return; } if (npc.alpha > 0) { npc.alpha -= 5; } if (timer++ > 600) { timer = 0; redirectTimer = 0; } if (timer % 300 == 0 && timer != 0) { Attack(); } if (timer % 180 == 0) { if (FacingWall()) { npc.velocity.Y -= 5f; } else { npc.velocity.Y -= 3f; } SyncNPC(); } if (canSee()) { if (OnGround()) { npc.velocity.X -= direction ? 0.25f * -1 : 0.25f; } else { npc.velocity.X -= direction ? 8f * -1 : 8f; } } else { npc.velocity.X += pathing * 1f; if (FacingWall() && redirectTimer++ % 180 == 0) { pathing *= -1; } } if (BottomLeftTile() && !TopLeftTile() && npc.velocity.X < 0f) { npc.position.X -= 2f; npc.position.Y -= 8f; } if (BottomRightTile() && !TopRightTile() && npc.velocity.X > 0f) { npc.position.X += 2f; npc.position.Y -= 8f; } ArchaeaNPC.VelClampX(npc, -3f, 3f); if (npc.velocity.X < 0f && npc.oldVelocity.X >= 0f || npc.velocity.X > 0f && npc.oldVelocity.X <= 0f || npc.velocity.Y < 0f && npc.oldVelocity.Y >= 0f || npc.velocity.Y > 0f && npc.oldVelocity.Y <= 0f) { SyncNPC(); } }
public override bool PreAI() { if (time++ > frameCount * frameTime) { time = 0; } if (!chosenTexture) { int rand = Main.rand.Next(4); switch (rand) { case 0: break; case 1: Main.npcTexture[npc.type] = mod.GetTexture("Gores/Sky_1_1"); npc.defense = 30; npc.netUpdate = true; break; case 2: Main.npcTexture[npc.type] = mod.GetTexture("Gores/Sky_1_2"); npc.defense = 20; npc.netUpdate = true; break; case 3: Main.npcTexture[npc.type] = mod.GetTexture("Gores/Sky_1_3"); npc.defense = 25; npc.netUpdate = true; break; } chosenTexture = true; } if (!init) { int i = (int)npc.position.X / 16; int j = (int)npc.position.Y / 16; if (ArchaeaWorld.Inbounds(i, j) && Main.tile[i, j].wall != ArchaeaWorld.skyBrickWall) { newPosition = ArchaeaNPC.FindAny(npc, target(), true, 800); if (newPosition != Vector2.Zero) { npc.netUpdate = true; if (Main.netMode == 0) { npc.position = newPosition; } } else { return(false); } } oldX = npc.position.X; upperPoint = npc.position.Y - 50f; idle = npc.position; upper = new Vector2(oldX, upperPoint); init = true; } return(PreSkyAI() && BeginActive()); }
public override void RandomUpdate(int i, int j, int type) { if (!ArchaeaWorld.Inbounds(i, j)) { return; } if (Main.rand.NextFloat() > 0.95f && type == ArchaeaWorld.magnoStone) { int count = 0; ushort[] types = new ushort[] { ArchaeaWorld.crystal, ArchaeaWorld.crystal2x1, ArchaeaWorld.crystal2x2, ArchaeaWorld.crystalLarge }; for (int k = i - 8; k < i + 8; k++) { for (int l = j - 8; l < j + 8; l++) { foreach (ushort t in types) { if (Main.tile[k, l].type == t) { count++; } } } } if (count == 0) { Tile top = Main.tile[i, j + 1]; Tile right = Main.tile[i + 1, j]; Tile bottom = Main.tile[i, j - 1]; Tile left = Main.tile[i - 1, j]; if (type == ArchaeaWorld.magnoStone) { if (!top.active()) { WorldGen.PlaceTile(i, j - 1, (int)types[0], true, false, -1, 3); } else if (!right.active()) { WorldGen.PlaceTile(i, j - 1, (int)types[0], true, false, -1, 1); } else if (!bottom.active()) { if (Main.rand.NextBool()) { WorldGen.PlaceTile(i, j - 1, Main.rand.Next(new int[] { (int)types[0], (int)types[1], (int)types[2] }), true, false, -1, 0); } else if (Main.hardMode) { WorldGen.PlaceTile(i, j - 1, types[3], true, false); } } else if (!left.active()) { WorldGen.PlaceTile(i, j - 1, (int)types[0], true, false, -1, 2); } } } } }
public override void AI() { time++; if (!init) { int i = (int)npc.position.X / 16; int j = (int)npc.position.Y / 16; if (ArchaeaWorld.Inbounds(i, j) && Main.tile[i, j].wall != ArchaeaWorld.skyBrickWall) { newPosition = ArchaeaNPC.FindAny(npc, ArchaeaNPC.FindClosest(npc, true), true, 800); if (newPosition != Vector2.Zero) { npc.netUpdate = true; init = true; } } } if (newPosition != Vector2.Zero && ai == Idle) { npc.position = newPosition; } if (time > 150) { if (npc.alpha > 12) { npc.alpha -= 12; } else { npc.alpha = 0; } } if (npc.target == 255) { if (npc.life < npc.lifeMax) { npc.TargetClosest(); } return; } if (time > 300) { time = 0; ai = Attack; } if (time == 240) { tracking = npcTarget.Center; } if (ai == Attack) { npc.velocity += ArchaeaNPC.AngleToSpeed(npc.AngleTo(tracking), rushSpeed); ai = Activated; npc.netUpdate = true; } else { ArchaeaNPC.SlowDown(ref npc.velocity, 0.2f); if (time % 45 == 0 && time != 0) { npc.velocity = Vector2.Zero; } } if (npc.velocity.X >= npc.oldVelocity.X || npc.velocity.X < npc.oldVelocity.X || npc.velocity.Y >= npc.oldVelocity.Y || npc.velocity.Y < npc.oldVelocity.Y) { npc.netUpdate = true; } if (npc.Center.X <= npcTarget.Center.X) { float angle = (float)Math.Round(Math.PI * 0.2f, 1); if (npc.rotation > angle) { npc.rotation -= rotateSpeed; } else { npc.rotation += rotateSpeed; } } else { float angle = (float)Math.Round((Math.PI * 0.2f) * -1, 1); if (npc.rotation > angle) { npc.rotation -= rotateSpeed; } else { npc.rotation += rotateSpeed; } } if (ai == Idle && npc.Distance(npcTarget.Center) < 64f) { ArchaeaNPC.DustSpread(npc.position, npc.width, npc.height, DustID.Stone, 5, 1.2f); npc.TargetClosest(); ai = Activated; npc.netUpdate = true; } }
public override void PostUpdate() { ArchaeaWorld modWorld = mod.GetModWorld <ArchaeaWorld>(); #region item checks for (int k = 0; k < player.armor.Length; k++) { if (player.armor[k].type == mod.ItemType <Items.magno_shieldacc>()) { magnoShield = true; break; } else { magnoShield = false; } } for (int k = 0; k < player.armor.Length; k++) { if (player.armor[k].type == mod.ItemType <Items.Armors.magnoheadgear>()) { magnoRanged = true; break; } else { magnoRanged = false; } } #endregion if (MagnoZone && !modWorld.MagnoDefeated) { if (!player.HasBuff(mod.BuffType <Buffs.magno_cursed>())) { player.AddBuff(BuffID.WaterCandle, debuffTime, true); } } if (!modWorld.MagnoDefeated) { if (player.position.Y > (Main.maxTilesY * tileSize) - hellLayer * tileSize) { player.AddBuff(BuffID.OnFire, debuffTime, false); if (!flag) { Main.NewText("Energy from the red crystals gathers here", 210, 110, 110); flag = true; } } } // if (Main.netMode == 0) // { /* player.statLife = player.statLifeMax; * if (Main.mouseMiddle) * { * Main.dayTime = true; * Main.time = 12400; * // Main.NewText("Location: i, " + Math.Round(player.position.X / 16, 0) + " j, " + Math.Round(player.position.Y / 16, 0), Color.White); * // Main.dayTime = false; * // Main.time = 12400; * } */ // } if (ticks == 0) { //int chest = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.Chest, 10, true, -1, true, false); //int item = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.EoCShield, 1, true, -1, true, false); // int item = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.EoCShield, 1, true, -1, true, false); //int ammoArrows = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.FrostburnArrow, 999, true, -1, true, false); int item2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.RegenerationPotion, 10, true, -1, true, false); int item3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.IronskinPotion, 10, true, -1, true, false); int item4 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.SwiftnessPotion, 10, true, -1, true, false); //int item5 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.HeartLantern, 1, true, -1, true, false); //int item6 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.HealingPotion, 30, true, -1, true, false); //int item7 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.Campfire, 1, true, -1, true, false); //int item8 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.TeleportationPotion, 30, true, -1, true, false); //int item9 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.WormholePotion, 30, true, -1, true, false); //int throwing = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.cinnabar_dagger>(), 999, true, -1, true, false); //int throwing2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.magno_javelin>(), 999, true, -1, true, false); //int throwing3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.Beenade, 250, true, -1, true, false); //int throwing4 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.MolotovCocktail, 99, true, -1, true, false); //int weapon = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.MagicMissile, 1, true, -1, true, false); //int weapon2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.ThornChakram, 1, true, -1, true, false); //int weapon3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.WaterBolt, 1, true, -1, true, false); //int weapon4 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.magno_yoyo>(), 1, true, -1, true, false); //int weapon5 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.AquaScepter, 1, true, -1, true, false); //int weapon6 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.magno_book>(), 1, true, -1, true, false); // int item8 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.Armors.magnoheadgear>(), 1, true, -1, true, false); // int item9 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.Armors.magnoplate>(), 1, true, -1, true, false); // int item10 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.Armors.magnogreaves>(), 1, true, -1, true, false); // int item11 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), mod.ItemType<Items.magno_summonstaff>(), 1, true, -1, true, false); //int head = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.FossilHelm, 1, true, -1, true, false); //int body = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.FossilShirt, 1, true, -1, true, false); //int legs = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.FossilPants, 1, true, -1, true, false); //int head2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.JungleHat, 1, true, -1, true, false); //int body2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.JungleShirt, 1, true, -1, true, false); //int legs2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.JunglePants, 1, true, -1, true, false); //int head3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.NecroHelmet, 1, true, -1, true, false); //int body3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.NecroBreastplate, 1, true, -1, true, false); //int legs3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.NecroGreaves, 1, true, -1, true, false); /* int head4 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.SilverHelmet, 1, true, -1, true, false); * int body4 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.SilverChainmail, 1, true, -1, true, false); * int legs4 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.SilverGreaves, 1, true, -1, true, false); * int weapon = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.PlatinumBow, 1, true, -1, true, false); * int pickaxe = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.SilverPickaxe, 1, true, -1, true, false); * int axe = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.SilverAxe, 1, true, -1, true, false); * int hammer = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.SilverHammer, 1, true, -1, true, false); */ // int ammoArrows = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.JestersArrow, 999, true, -1, true, false); // int ammoBullets = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.MusketBall, 999, true, -1, true, false); //int acc = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.CloudinaBottle, 1, true, -1, true, false); // int acc2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.ShoeSpikes, 1, true, -1, true, false); //int acc3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.MagicMirror, 1, true, -1, true, false); // int acc4 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.CobaltShield, 1, true, -1, true, false); // int dummy = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.TargetDummy, 1, true, -1, true, false); //int dpsMeter = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.DPSMeter, 1, true, -1, true, false); /* int ammoArrows2 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.WoodenArrow, 1998, true, -1, true, false); * int ammoArrows3 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.JestersArrow, 999, true, -1, true, false); * int voodooDolls = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.GuideVoodooDoll, 3, true, -1, true, false); * int acc5 = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.LavaCharm, 1, true, -1, true, false); * int bridgeBlocks = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.IceBlock, 2997, true, -1, true, false); */ //int lifeCrystals = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.LifeCrystal, 10, true, -1, true, false); //int manaCrystals = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.ManaCrystal, 4, true, -1, true, false); //int mount = Item.NewItem(new Rectangle((int)player.position.X, (int)player.position.Y, 0, 0), ItemID.FuzzyCarrot, 1, true, -1, true, false); ticks = 1; } }