Ejemplo n.º 1
0
        public Vector2 GetStandOnPoint(NPC npc)
        {
            float scalar          = npc.velocity.Length();
            float outerLegDefault = 70f + (0.5f * scalar);
            float innerLegDefault = 50f + (0.5f * scalar);
            float rightLegScalar  = 1f + (npc.velocity.X > 2f ? (scalar * 0.2f) : 0f); //fixes an offset problem when the npc walks right
            float standOnX        = npc.Center.X + yamata.topVisualOffset.X + (limbType == 3 ? (-outerLegDefault - Hitbox.Width) : limbType == 2 ? (outerLegDefault + Hitbox.Width) : limbType == 1 ? (-innerLegDefault - Hitbox.Width) : (innerLegDefault + Hitbox.Width));

            int defaultTileY = (int)(npc.Bottom.Y / 16f);
            int tileY        = BaseWorldGen.GetFirstTileFloor((int)(standOnX / 16f), (int)(npc.Bottom.Y / 16f));

            if (tileY - defaultTileY > Yamata.flyingTileCount)
            {
                return(default(Vector2));
            }                                                                               //'flying' behavior
            if (!flying)
            {
                tileY = (int)((int)((float)tileY * 16f) / 16);
                float tilePosY = ((float)tileY * 16f);
                if (Main.tile[(int)(standOnX / 16f), tileY] == null || !Main.tile[(int)(standOnX / 16f), tileY].nactive() || !Main.tileSolid[Main.tile[(int)(standOnX / 16f), tileY].type])
                {
                    tilePosY += 16f;
                }
                return(new Vector2(standOnX - (Hitbox.Width * 0.5f), tilePosY - Hitbox.Height));
            }
            return(default(Vector2));
        }
Ejemplo n.º 2
0
        public void InfernoVolcano()
        {
            Point origin = new Point((int)infernoPos.X, (int)infernoPos.Y);

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            InfernoBiome biome = new InfernoBiome();

            biome.Place(origin, WorldGen.structures);
        }
Ejemplo n.º 3
0
        public void MireAbyss()
        {
            Point origin = new Point((int)mirePos.X, (int)mirePos.Y);

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            MireBiome biome = new MireBiome();

            biome.Place(origin, WorldGen.structures);
        }
Ejemplo n.º 4
0
        public void PreShrine()
        {
            Point origin = new Point((int)(Main.maxTilesX * 0.60f), (int)(Main.maxTilesY * 0.05f));

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            WorldUtils.Gen(origin, new Shapes.Rectangle(80, 50), Actions.Chain(new GenAction[] //remove all fluids in rectangle
            {
                new Actions.SetLiquid(0, 0)
            }));
        }
Ejemplo n.º 5
0
        public void InfectionCave()
        {
            Point origin = new Point((int)(Main.maxTilesX * Main.rand.Next(.1f, .9f)), (int)(Main.maxTilesY * Main.rand.Next(.4f, .8f)));

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            InfectionClear delete = new InfectionClear();
            InfectionCave  biome  = new InfectionCave();

            delete.Place(origin, WorldGen.structures);
            biome.Place(origin, WorldGen.structures);
        }
Ejemplo n.º 6
0
        public void CrimsonSeptetteBegin()
        {
            Point origin = new Point((int)((int)OvergrowthPos2.X), ((int)OvergrowthPos2.Y));;

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            CrimsonSeptetteDelete delete = new CrimsonSeptetteDelete();
            CrimsonSeptette       biome  = new CrimsonSeptette();

            delete.Place(origin, WorldGen.structures);
            biome.Place(origin, WorldGen.structures);
        }
Ejemplo n.º 7
0
        public void FloweringNightsBegin()
        {
            Point origin = new Point((int)((int)OvergrowthPos.X), ((int)OvergrowthPos.Y));;

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            FloweringNightsDelete delete = new FloweringNightsDelete();
            FloweringNights       biome  = new FloweringNights();

            delete.Place(origin, WorldGen.structures);
            biome.Place(origin, WorldGen.structures);
        }
Ejemplo n.º 8
0
        public void GreatDarknessH()
        {
            Point origin = new Point((int)greatDarknessPos.X, (int)greatDarknessPos.Y);

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            GreatDarkness       biome  = new GreatDarkness();
            GreatDarknessDelete delete = new GreatDarknessDelete();

            delete.Place(origin, WorldGen.structures);
            biome.Place(origin, WorldGen.structures);
        }
Ejemplo n.º 9
0
        public Vector2 GetStandOnPoint(NPC npc)
        {
            float scalar          = npc.velocity.Length();
            float outerLegDefault = 150f + (0.5f * scalar);
            float innerLegDefault = 120f + (0.5f * scalar);
            float standOnX        = npc.Center.X + yamataA.topVisualOffset.X + (limbType == 3 ? (-outerLegDefault - Hitbox.Width) : limbType == 2 ? (outerLegDefault + Hitbox.Width) : limbType == 1 ? (-innerLegDefault - Hitbox.Width) : (innerLegDefault + Hitbox.Width));

            int defaultTileY = (int)(npc.Bottom.Y / 16f);
            int tileY        = BaseWorldGen.GetFirstTileFloor((int)(standOnX / 16f), (int)(npc.Bottom.Y / 16f));

            if (tileY - defaultTileY > YamataA.flyingTileCount)
            {
                return(default);
Ejemplo n.º 10
0
        public override bool UseItem(Player player)
        {
            GrowthBiome biome  = new GrowthBiome();
            Point       origin = new Point((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f));

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y) - 10;
            bool desobj = WorldGen.destroyObject;

            WorldGen.destroyObject = true;
            biome.Place(origin, WorldGen.structures);
            WorldGen.destroyObject = desobj;
            return(true);
        }
Ejemplo n.º 11
0
        public void InfectionCave(GenerationProgress progress)
        {
            int x      = Main.maxTilesX;
            int y      = Main.maxTilesY;
            int tilesX = WorldGen.genRand.Next(300, x - 300);
            int tilesY = WorldGen.genRand.Next((int)(y * .3f), (int)(y * .75f));

            Point origin = new Point(tilesX, tilesY);

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            InfectionClear delete = new InfectionClear();
            InfectionCave  biome  = new InfectionCave();

            delete.Place(origin, WorldGen.structures);
            biome.Place(origin, WorldGen.structures);
        }
Ejemplo n.º 12
0
        public override bool UseItem(Player player)
        {
            int x      = Main.maxTilesX;
            int y      = Main.maxTilesY;
            int tilesX = (int)player.Center.X;
            int tilesY = (int)player.Center.Y;

            Point origin = new Point(tilesX, tilesY);

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            InfectionClear delete = new InfectionClear();
            InfectionCave  biome  = new InfectionCave();

            delete.Place(origin, WorldGen.structures);
            biome.Place(origin, WorldGen.structures);
            return(true);
        }
Ejemplo n.º 13
0
        public override bool UseItem(Player player)
        {
            Mod mod = AAMod.instance;
            Dictionary <Color, int> colorToTile = new Dictionary <Color, int>();

            colorToTile[new Color(255, 0, 0)]     = mod.TileType("Torchstone");
            colorToTile[new Color(0, 0, 255)]     = mod.TileType("Torchstone");
            colorToTile[new Color(150, 150, 150)] = -2; //turn into air
            colorToTile[Color.Black] = -1;              //don't touch when genning

            Dictionary <Color, int> colorToWall = new Dictionary <Color, int>();

            colorToWall[new Color(255, 0, 0)] = mod.WallType("TorchstoneWall");
            colorToWall[Color.Black]          = -1; //don't touch when genning

            TexGen gen    = BaseWorldGenTex.GetTexGenerator(mod.GetTexture("Worldgeneration/Volcano"), colorToTile, mod.GetTexture("Worldgeneration/VolcanoWalls"), colorToWall, mod.GetTexture("Worldgeneration/VolcanoLava"));
            Point  origin = new Point((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f));

            origin.Y = BaseWorldGen.GetFirstTileFloor(origin.X, origin.Y, true);
            gen.Generate(origin.X, origin.Y - 40, true, true);
            return(true);
        }
Ejemplo n.º 14
0
        public override void AI()
        {
            if (!HeadsSpawned)
            {
                if (Main.netMode != 1)
                {
                    int latestNPC = npc.whoAmI;
                    latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 60, mod.NPCType("HydraHead1"), 0, npc.whoAmI);
                    Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                    Main.npc[(int)latestNPC].ai[0]    = npc.whoAmI;
                    Head1     = Main.npc[latestNPC];
                    latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 60, mod.NPCType("HydraHead2"), 0, npc.whoAmI);
                    Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                    Main.npc[(int)latestNPC].ai[0]    = npc.whoAmI;
                    Head2     = Main.npc[latestNPC];
                    latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 60, mod.NPCType("HydraHead3"), 0, npc.whoAmI);
                    Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                    Main.npc[(int)latestNPC].ai[0]    = npc.whoAmI;
                    Head3 = Main.npc[latestNPC];
                }
                HeadsSpawned = true;
            }
            if (playerTarget != null)
            {
                float dist = npc.Distance(playerTarget.Center);
                if (dist > 1000)
                {
                    if (!chasePlayer)
                    {
                        npc.netUpdate = true;
                    }
                    chasePlayer       = true;
                    npc.noTileCollide = true;
                }
                else
                {
                    if (chasePlayer)
                    {
                        npc.netUpdate = true;
                    }
                    chasePlayer       = false;
                    npc.noTileCollide = false;
                }
            }
            for (int m = npc.oldPos.Length - 1; m > 0; m--)
            {
                npc.oldPos[m] = npc.oldPos[m - 1];
            }
            npc.oldPos[0] = npc.position;

            bool foundTarget = TargetClosest();

            if (foundTarget)
            {
                int tileY = BaseWorldGen.GetFirstTileFloor((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f));
                npc.timeLeft = 300;
                float playerDistance = Vector2.Distance(playerTarget.Center, npc.Center);
                if (Math.Abs(npc.velocity.X) > 12f)
                {
                    npc.velocity.X *= 0.8f;
                }
                if (Math.Abs(npc.velocity.Y) > 12f)
                {
                    npc.velocity.Y *= 0.8f;
                }
                if (npc.velocity.Y > 7f)
                {
                    npc.velocity.Y *= 0.75f;
                }
                AIMovementNormal();
            }
            else
            {
                AIMovementRunAway();
            }
            bottomVisualOffset = new Vector2(Math.Min(3f, Math.Abs(npc.velocity.X)), 30f) * (npc.velocity.X < 0 ? 1 : -1);
        }
Ejemplo n.º 15
0
        public override void AI()
        {
            if (Tag)
            {
                npc.life = 0;
                npc.checkDead();
                npc.netUpdate = true;
            }

            Main.dayTime = false;
            Main.time    = 24000;

            if (isAwakened)
            {
                MinionTimer++;
                if (MinionTimer == 300 && NPC.CountNPCS(mod.NPCType <YamataSoul>()) < 6)
                {
                    NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType <YamataSoul>());

                    MinionTimer = 0;
                }
            }

            if (!HeadsSpawned)
            {
                if (Main.netMode != 1)
                {
                    headsSaidOw = new bool[7];
                    if (isAwakened)
                    {
                        npc.realLife = npc.whoAmI;
                        int latestNPC = npc.whoAmI;
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataAHead"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                        Main.npc[(int)latestNPC].ai[0]    = npc.whoAmI;
                        TrueHead = Main.npc[latestNPC];
                    }
                    else
                    {
                        int latestNPC = npc.whoAmI;
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataHead"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].realLife = npc.whoAmI;
                        Main.npc[(int)latestNPC].ai[0]    = npc.whoAmI;
                        TrueHead  = Main.npc[latestNPC];
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataHeadF1"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].ai[0] = npc.whoAmI;
                        Head2     = Main.npc[latestNPC];
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataHeadF1"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].ai[0] = npc.whoAmI;
                        Head3     = Main.npc[latestNPC];
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataHeadF1"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].ai[0] = npc.whoAmI;
                        Head4     = Main.npc[latestNPC];
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataHeadF2"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].ai[0] = npc.whoAmI;
                        Head5     = Main.npc[latestNPC];
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataHeadF2"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].ai[0] = npc.whoAmI;
                        Head6     = Main.npc[latestNPC];
                        latestNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, mod.NPCType("YamataHeadF2"), 0, npc.whoAmI);
                        Main.npc[(int)latestNPC].ai[0] = npc.whoAmI;
                        Head7 = Main.npc[latestNPC];
                    }
                }
                HeadsSpawned = true;
            }
            else
            {
                CheckOnHeads();
            }

            if (isAwakened && npc.life <= npc.lifeMax / 5)
            {
                int newMusic = mod.GetSoundSlot(Terraria.ModLoader.SoundType.Music, "Sounds/Music/RayOfHope");
                if (music != newMusic)
                {
                    BaseUtility.Chat("YOU THINK I'M DONE YET?! I DON'T THINK SO!!!!", new Color(146, 30, 68));
                }
                music = mod.GetSoundSlot(Terraria.ModLoader.SoundType.Music, "Sounds/Music/RayOfHope");
            }

            prevHalfHPLeft   = halfHPLeft;
            prevFourthHPLeft = fourthHPLeft;
            halfHPLeft       = (halfHPLeft || npc.life <= npc.lifeMax / 2);
            fourthHPLeft     = (fourthHPLeft || npc.life <= npc.lifeMax / 4);

            if (playerTarget != null)
            {
                float dist = npc.Distance(playerTarget.Center);
                if (dist > 1200)
                {
                    if (!npc.noTileCollide && Main.netMode != 1)
                    {
                        BaseUtility.Chat("ARE YOU RUNNING AWAY?! GET BACK HERE!!", isAwakened ? new Color(146, 30, 68) : new Color(45, 46, 70));
                    }
                    npc.noTileCollide = true;
                }
                else
                {
                    npc.noTileCollide = false;
                }
            }
            for (int m = npc.oldPos.Length - 1; m > 0; m--)
            {
                npc.oldPos[m] = npc.oldPos[m - 1];
            }
            npc.oldPos[0] = npc.position;

            bool foundTarget = TargetClosest();

            if (foundTarget)
            {
                int tileY = BaseWorldGen.GetFirstTileFloor((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f));
                npc.timeLeft = 300;
                float playerDistance = Vector2.Distance(playerTarget.Center, npc.Center);
                if ((playerDistance < playerTooFarDist - 100f) && Math.Abs(npc.velocity.X) > 12f)
                {
                    npc.velocity.X *= 0.8f;
                }
                if ((playerDistance < playerTooFarDist - 100f) && Math.Abs(npc.velocity.Y) > 12f)
                {
                    npc.velocity.Y *= 0.8f;
                }
                if (npc.velocity.Y > 7f)
                {
                    npc.velocity.Y *= 0.75f;
                }
                AIMovementNormal();
            }
            else
            {
                AIMovementRunAway();
            }

            //topVisualOffset = new Vector2(Math.Min(8f, Math.Abs(npc.velocity.X) * 2f), 0f) * (npc.velocity.X < 0 ? 1 : -1);
            bottomVisualOffset = new Vector2(Math.Min(3f, Math.Abs(npc.velocity.X)), 0f) * (npc.velocity.X < 0 ? 1 : -1);
            UpdateLimbs();
        }