Exemple #1
0
        private void NpcPostUpdate(NPC npc, int i)
        {
            if (npc == null || i > Main.npc.Length - 1 || i < 0 || !npc.active)
            {
                return;
            }

            if (npc.type == 68)
            {
                if (!Guardians.ContainsKey(i))
                {
                    Guardians.Add(i, DateTime.UtcNow);
                }
            }
            else if (Main.dayTime && (npc.type == 127 || npc.type == 35 || npc.type == 636))
            {
                Main.npc[i] = new NPC();
                NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, i);
            }

            int bossId = (npc.type == 233 || npc.type == 13 || npc.type == 14 || npc.type == 15 ? 6969 : npc.type);

            if (npc.type == 126 || npc.type == 125 || npc.type == 134 || npc.type == 127 || npc.type == 128 || npc.type == 129 ||
                npc.type == 130 || npc.type == 131)
            {
                bossId = 42069;
            }

            if (!Goals.IsDone(bossId))
            {
                Main.npc[i] = new NPC();
                NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, i);
            }
        }
Exemple #2
0
        public static bool Tile(BinaryReader read, TSPlayer who)
        {
            byte   b    = read.ReadByte();
            short  x    = read.ReadInt16();
            short  y    = read.ReadInt16();
            ushort num3 = read.ReadUInt16();

            if (who == null)
            {
                return(false);
            }
            if (TShock.Regions.CanBuild(x, y, who))
            {
                return(false);
            }
            if (b == 0)
            {
                switch (Main.tile[x, y].type)
                {
                case 0:
                case 1:
                case 40:
                case 59:
                case 123:
                    if (y > Main.worldSurface - 150.0)
                    {
                        Random random = new Random();
                        if (random.Next(0, 1550) <= 2)
                        {
                            int num4 = random.Next(35, 85);
                            SurvivalCore.SrvPlayers[who.Index].Money += num4;
                            who.SendInfoMessage($"Znalazles mieszek, a w nim {num4} €.");
                        }
                    }

                    break;

                case 238:
                {
                    if (!Goals.IsDone(262))
                    {
                        who.SendErrorMessage("Ten boss w tej chwili jest zablokowany.");
                        who.SendTileSquare(x, y);
                        return(true);
                    }

                    if ((SurvivalCore.SrvPlayers[who.Index].BossCooldown - DateTime.Now).TotalSeconds > 0)
                    {
                        who.SendErrorMessage($"Musisz odczekac jakis czas, aby moc zrespic kolejnego bossa/inwazje. Mozliwe to bedzie za {PowelderAPI.Utils.ExpireCountDown(SurvivalCore.SrvPlayers[who.Index].BossCooldown)}");
                        who.SendTileSquare(x, y);
                        return(true);
                    }

                    break;
                }
                }
            }
            return(false);
        }
Exemple #3
0
        public static bool StrikeNpc(BinaryReader read, TSPlayer who)
        {
            short npcid     = read.ReadInt16();
            short damage    = read.ReadInt16();
            float knockback = read.ReadSingle();

            read.ReadByte();
            bool   crit        = read.ReadBoolean();
            NPC    npc         = Main.npc[npcid];
            double finalDamage = Main.CalculateDamageNPCsTake(damage, npc.defense);

            if (crit)
            {
                finalDamage *= 2.0;
            }

            bool isDead = false || npc.life - finalDamage <= 0;

            if (npc.type == 661)
            {
                if (Main.dayTime)
                {
                    who.SendErrorMessage("Wolimy uniknac masowej rzezni.");
                    return(true);
                }

                if (!Goals.IsDone(636))
                {
                    who.SendErrorMessage("Ten boss w tej chwili jest zablokowany.");
                    return(true);
                }


                if ((SurvivalCore.SrvPlayers[who.Index].BossCooldown - DateTime.Now).TotalSeconds > 0)
                {
                    who.GiveItem(SpawnItemId(npcid), 1);
                    who.SendErrorMessage($"Musisz odczekac jakis czas, aby moc zrespic kolejnego bossa. Mozliwe to bedzie za {PowelderAPI.Utils.ExpireCountDown(SurvivalCore.SrvPlayers[who.Index].BossCooldown)}");
                    return(true);
                }
            }
            return(false);
        }
Exemple #4
0
        public static bool SpecialNpcEffect(BinaryReader read, TSPlayer who)
        {
            byte b  = read.ReadByte();
            byte b2 = read.ReadByte();

            if (b2 == 1)
            {
                if (!Goals.IsDone(35))
                {
                    who.SendErrorMessage("Ten boss w tej chwili jest zablokowany.");
                    return(true);
                }

                if ((SurvivalCore.SrvPlayers[who.Index].BossCooldown - DateTime.Now).TotalSeconds > 0)
                {
                    who.SendErrorMessage($"Musisz odczekac jakis czas, aby moc zrespic kolejnego bossa. Mozliwe to bedzie za {PowelderAPI.Utils.ExpireCountDown(SurvivalCore.SrvPlayers[who.Index].BossCooldown)}");
                    return(true);
                }
            }
            return(false);
        }
Exemple #5
0
        public static void Przywolywanie(TShockAPI.CommandArgs args)
        {
            string text  = null;
            string text2 = null;

            if (args.Parameters.Count > 0)
            {
                text = args.Parameters[0].ToLower();
            }

            if (args.Parameters.Count > 1)
            {
                text2 = args.Parameters[1].ToLower();
            }

            if ((SurvivalCore.SrvPlayers[args.Player.Index].BossCooldown - DateTime.Now).TotalSeconds > 0)
            {
                args.Player.SendErrorMessage($"Musisz odczekac jakis czas, aby moc zrespic kolejnego bossa. Mozliwe to bedzie za {PowelderAPI.Utils.ExpireCountDown(SurvivalCore.SrvPlayers[args.Player.Index].BossCooldown)}");
                return;
            }

            switch (text)
            {
            default:
                args.Player.SendErrorMessage("Uzycie: /przywolaj <co>");
                break;

            case "wof":
            case "wall of flesh":
            {
                Item itemById = TShock.Utils.GetItemById(267);
                if (PowelderAPI.Utils.PlayerItemCount(args.Player, itemById) < 1)
                {
                    args.Player.SendErrorMessage("Nie masz wymaganych materialow w ekwipunku.");
                    args.Player.SendErrorMessage("Wymagane:  [i:267]");
                    break;
                }

                if (!Goals.IsDone(113))
                {
                    args.Player.SendErrorMessage("Ten boss w tej chwili jest zablokowany.");
                    return;
                }

                if (Main.wofNPCIndex >= 0)
                {
                    args.Player.SendErrorMessage("Wall of Flesh juz jest na swiecie.");
                    break;
                }

                if (args.Player.Y / 16f < (float)(Main.maxTilesY - 205))
                {
                    args.Player.SendErrorMessage("Musisz byc w piekle, aby przywolac Wall of Flesha.");
                    break;
                }

                PowelderAPI.Utils.PlayerRemoveItems(args.Player, itemById, 1);
                NPC.SpawnWOF(new Vector2(args.Player.X, args.Player.Y));
                TSPlayer.All.SendInfoMessage("{0} przywolal Wall of Flesha.", args.Player.Name);
                break;
            }

            case "lunatic":
            case "Lun":
            case "lc":
            case "lunatic cultist":
            {
                NPC nPc2 = new NPC();
                nPc2.SetDefaults(439);
                if (!NPC.downedGolemBoss)
                {
                    args.Player.SendErrorMessage("Przywolanie bedzie mozliwe po pokonaniu Golema.");
                    break;
                }

                if (!Goals.IsDone(439))
                {
                    args.Player.SendErrorMessage("Ten boss w tej chwili jest zablokowany.");
                    return;
                }

                if (PowelderAPI.Utils.IsNpcOnWorld(nPc2.type))
                {
                    args.Player.SendErrorMessage("Lunatic Cultist juz jest na swiecie.");
                    break;
                }


                if (PowelderAPI.Utils.PlayerItemCount(args.Player, TShock.Utils.GetItemById(1274)) < 1 ||
                    PowelderAPI.Utils.PlayerItemCount(args.Player, TShock.Utils.GetItemById(148)) < 5)
                {
                    args.Player.SendErrorMessage("Nie masz wymaganych materialow w ekwipunku.");
                    args.Player.SendErrorMessage("Wymagane:  [i:1274] [i/s5:148]");
                    break;
                }

                PowelderAPI.Utils.PlayerRemoveItems(args.Player, TShock.Utils.GetItemById(1274), 1);
                PowelderAPI.Utils.PlayerRemoveItems(args.Player, TShock.Utils.GetItemById(148), 5);
                TSPlayer.Server.SpawnNPC(nPc2.type, nPc2.FullName, 1, args.Player.TileX, args.Player.TileY);
                break;
            }

            case "martians":
            case "martian madness":
            case "mm":
            case "martian":
            {
                if (!NPC.downedGolemBoss)
                {
                    args.Player.SendErrorMessage("Przywolanie bedzie mozliwe po pokonaniu Golema.");
                    break;
                }

                if (Main.invasionType != 0)
                {
                    args.Player.SendErrorMessage("Na swiecie juz jest jakas inwazja.");
                    break;
                }

                int cost = Utils.CostCalc(args.Player, 3500);
                if (SurvivalCore.SrvPlayers[args.Player.Index].Money < cost)
                {
                    args.Player.SendErrorMessage("Nie stac Cie na rozpoczecie tego eventu. Koszt to {0} €", cost);
                    break;
                }

                if (PowelderAPI.Utils.PlayerItemCount(args.Player, TShock.Utils.GetItemById(3118)) < 1 ||
                    PowelderAPI.Utils.PlayerItemCount(args.Player, TShock.Utils.GetItemById(530)) < 95)
                {
                    args.Player.SendErrorMessage("Nie masz wymaganych materialow w ekwipunku.");
                    args.Player.SendErrorMessage("Wymagane:  [i:3118] [i/s5:148]");
                }
                else
                {
                    PowelderAPI.Utils.PlayerRemoveItems(args.Player, TShock.Utils.GetItemById(3118), 1);
                    PowelderAPI.Utils.PlayerRemoveItems(args.Player, TShock.Utils.GetItemById(530), 95);
                }

                break;
            }

            case "skeletron":
            case "skele":
            {
                NPC nPc = new NPC();
                nPc.SetDefaults(35);
                if (!NPC.downedBoss3)
                {
                    args.Player.SendErrorMessage("Przywolanie bedzie mozliwe po pierwszym pokonaniu Skeletrona.");
                    break;
                }

                if (PowelderAPI.Utils.IsNpcOnWorld(nPc.type))
                {
                    args.Player.SendErrorMessage("Skeletron juz jest na swiecie.");
                    break;
                }

                if (Main.dayTime)
                {
                    args.Player.SendErrorMessage("Przywolanie jest mozliwe tylko w nocy.");
                    break;
                }


                if (PowelderAPI.Utils.PlayerItemCount(args.Player, TShock.Utils.GetItemById(1307)) < 1)
                {
                    args.Player.SendErrorMessage("Nie masz wymaganych materialow w ekwipunku.");
                    args.Player.SendErrorMessage("Wymagane:  [i:1307]");
                    break;
                }

                PowelderAPI.Utils.PlayerRemoveItems(args.Player, TShock.Utils.GetItemById(1307), 1);
                TSPlayer.Server.SpawnNPC(nPc.type, nPc.FullName, 1, args.Player.TileX, args.Player.TileY);
                TSPlayer.All.SendInfoMessage("{0} przywolal Skeletrona.", args.Player.Name);
                break;
            }
            }
        }
Exemple #6
0
        public static bool BossOrInvasionStart(BinaryReader read)
        {
            TSPlayer tSPlayer = TShock.Players[read.ReadInt16()];
            int      npcid    = read.ReadInt16();

            if ((DateTime.UtcNow - tSPlayer.LastThreat).TotalMilliseconds < 5000.0)
            {
                return(true);
            }

            bool isBoss;
            int  cost = 0;
            NPC  nPc  = new NPC();

            nPc.SetDefaults(npcid);
            isBoss = nPc.boss;
            if (!isBoss)
            {
                switch (npcid)
                {
                case 4:
                case 13:
                case 50:
                case 75:
                case 125:
                case 126:
                case 127:
                case 128:
                case 129:
                case 130:
                case 131:
                case 134:
                case 222:
                case 245:
                case 266:
                case 370:
                case 398:
                case 422:
                case 439:
                case 493:
                case 507:
                case 517:
                case 657:
                    isBoss = true;
                    break;
                }
            }

            switch (npcid)
            {
            case -1:
                cost = 1300;
                break;

            case -2:
                cost = 2650;
                break;

            case -3:
                cost = 2000;
                break;

            case -4:
                cost = 3100;
                break;

            case -5:
                cost = 4200;
                break;

            case -6:
                cost = 2700;
                break;

            case -7:
                cost = 15000;
                break;

            case -8:
                cost = 3000;
                break;

            case -10:
                cost = 500;
                break;
            }


            if (PowelderAPI.Utils.IsNpcOnWorld(125) && npcid == 126)
            {
                return(false);
            }

            int bossId = (npcid == 266 || npcid == 13 ? 6969 : npcid);

            if (npcid == 126 || npcid == 125 || npcid == 134 || npcid == 127 || npcid == 128 || npcid == 129 ||
                npcid == 130 || npcid == 131)
            {
                bossId = 42069;
            }

            if (!Goals.IsDone(bossId))
            {
                tSPlayer.SendErrorMessage("Ten boss w tej chwili jest zablokowany.");
                if (SpawnItemId(npcid) != -1)
                {
                    tSPlayer.GiveItem(SpawnItemId(npcid), 1);
                }

                return(true);
            }


            if ((SurvivalCore.SrvPlayers[tSPlayer.Index].BossCooldown - DateTime.Now).TotalSeconds > 0)
            {
                tSPlayer.SendErrorMessage(
                    $"Musisz odczekac jakis czas, aby moc zrespic kolejnego bossa/inwazje. Mozliwe to bedzie za {PowelderAPI.Utils.ExpireCountDown(SurvivalCore.SrvPlayers[tSPlayer.Index].BossCooldown)}");
                if (SpawnItemId(npcid) != -1 & npcid != 126)
                {
                    tSPlayer.GiveItem(SpawnItemId(npcid), 1);
                }

                return(true);
            }

            if (cost > 0)
            {
                cost = Utils.CostCalc(tSPlayer, cost);
                if (SurvivalCore.SrvPlayers[tSPlayer.Index].Money < cost)
                {
                    tSPlayer.SendErrorMessage("Nie stac cie na {0}. Koszt {1} €",
                                              isBoss ? ("przywolanie " + nPc.FullName) : ("rozpoczecie " + GetInvasion(npcid)), cost);
                    if (SpawnItemId(npcid) != -1)
                    {
                        tSPlayer.GiveItem(SpawnItemId(npcid), 1);
                    }

                    return(true);
                }

                SurvivalCore.SrvPlayers[tSPlayer.Index].Money -= cost;
            }


            SurvivalCore.SrvPlayers[tSPlayer.Index].BossCooldown = DateTime.Now.AddMinutes(30);


            return(false);
        }