Esempio n. 1
0
        //where x, y is the top-left hand corner of the gen
        public void Generate(int x, int y, bool silent, bool sync)
        {
            for (int x1 = 0; x1 < width; x1++)
            {
                for (int y1 = 0; y1 < height; y1++)
                {
                    int      x2 = x + x1, y2 = y + y1;
                    TileInfo info = tileGen[x1, y1];
                    if (info.liquidType == -2)
                    {
                        info.liquidType = 0;
                        info.liquidAmt  = 0;
                    }

                    if (info.tileID == -1 && info.wallID == -1 && info.liquidType == -1 && info.wire == -1)
                    {
                        continue;
                    }
                    if (info.tileID != -1 || info.wallID > -1 || info.wire > -1)
                    {
                        BaseWorldGen.GenerateTile(x2, y2, info.tileID, info.wallID, (info.tileStyle != 0 ? info.tileStyle : info.tileID == TileID.Torches ? torchStyle : info.tileID == TileID.Platforms ? platformStyle : 0), info.tileID > -1, info.liquidAmt == 0, info.slope, false, sync);
                    }
                    if (info.liquidType != -1)
                    {
                        BaseWorldGen.GenerateLiquid(x2, y2, info.liquidType, false, info.liquidAmt, sync);
                    }
                    if (info.objectID != 0)
                    {
                        WorldGen.PlaceObject(x2, y2, info.objectID);
                        NetMessage.SendObjectPlacment(-1, x2, y2, info.objectID, 0, 0, -1, -1);
                    }
                }
            }
        }
Esempio n. 2
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));
        }
Esempio 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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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)
            }));
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio 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);
        }
Esempio n. 11
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);
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
Esempio 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();
        }
Esempio n. 16
0
        public override bool PreAI()
        {
            npc.defense = Def();
            Vector2 chasePosition   = Main.npc[(int)npc.ai[1]].Center;
            Vector2 directionVector = chasePosition - npc.Center;

            npc.spriteDirection = (directionVector.X > 0f) ? 1 : -1;
            if (npc.ai[3] > 0)
            {
                npc.realLife = (int)npc.ai[3];
            }
            if (npc.target < 0 || npc.target == byte.MaxValue || Main.player[npc.target].dead)
            {
                npc.TargetClosest(true);
            }
            if (Main.player[npc.target].dead && npc.timeLeft > 300)
            {
                npc.timeLeft = 300;
            }

            if (Main.netMode != 1)
            {
                if (!Main.npc[(int)npc.ai[3]].active || Main.npc[(int)npc.ai[3]].type != mod.NPCType("GreedA"))
                {
                    npc.life = 0;
                    npc.HitEffect(0, 10.0);
                    npc.active = false;
                    NetMessage.SendData(28, -1, -1, null, npc.whoAmI, -1f, 0.0f, 0.0f, 0, 0, 0);
                }
            }

            if (npc.ai[1] < (double)Main.npc.Length)
            {
                Vector2 npcCenter = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
                float   dirX      = Main.npc[(int)npc.ai[1]].position.X + Main.npc[(int)npc.ai[1]].width / 2 - npcCenter.X;
                float   dirY      = Main.npc[(int)npc.ai[1]].position.Y + Main.npc[(int)npc.ai[1]].height / 2 - npcCenter.Y;
                npc.rotation = (float)Math.Atan2(dirY, dirX) + 1.57f;
                float length = (float)Math.Sqrt(dirX * dirX + dirY * dirY);
                float dist   = (length - npc.width) / length;
                float posX   = dirX * dist;
                float posY   = dirY * dist;

                if (dirX < 0f)
                {
                    npc.spriteDirection = 1;
                }
                else
                {
                    npc.spriteDirection = -1;
                }

                npc.velocity   = Vector2.Zero;
                npc.position.X = npc.position.X + posX;
                npc.position.Y = npc.position.Y + posY;
            }

            int tileX       = (int)(npc.position.X / 16f) - 1;
            int tileCenterX = (int)(npc.Center.X / 16f) + 2;
            int tileY       = (int)(npc.position.Y / 16f) - 1;
            int tileCenterY = (int)(npc.Center.Y / 16f) + 2;

            if (tileX < 0)
            {
                tileX = 0;
            }
            if (tileCenterX > Main.maxTilesX)
            {
                tileCenterX = Main.maxTilesX;
            }
            if (tileY < 0)
            {
                tileY = 0;
            }
            if (tileCenterY > Main.maxTilesY)
            {
                tileCenterY = Main.maxTilesY;
            }
            for (int tX = tileX; tX < tileCenterX; tX++)
            {
                for (int tY = tileY; tY < tileCenterY; tY++)
                {
                    Tile checkTile = BaseWorldGen.GetTileSafely(tX, tY);
                    if (checkTile != null && ((checkTile.nactive() && (Main.tileSolid[checkTile.type] || (Main.tileSolidTop[checkTile.type] && checkTile.frameY == 0))) || checkTile.liquid > 64))
                    {
                        Vector2 tPos;
                        tPos.X = tX * 16;
                        tPos.Y = tY * 16;
                        if (npc.position.X + npc.width > tPos.X && npc.position.X < tPos.X + 16f && npc.position.Y + npc.height > tPos.Y && npc.position.Y < tPos.Y + 16f)
                        {
                            if (Main.rand.Next(100) == 0 && checkTile.nactive())
                            {
                                WorldGen.KillTile(tX, tY, true, true, false);
                            }
                        }
                    }
                }
            }

            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            if (npc.alpha <= 0)
            {
                npc.alpha = 0;
                return(false);
            }
            else
            {
                for (int spawnDust = 0; spawnDust < 4; spawnDust++)
                {
                    int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, DustID.GoldCoin, 0f, 0f, 100, default, 2f);
Esempio n. 17
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);
        }