private void OnWorldSave(WorldSaveEventArgs args) { TSPlayer[] players = TShock.Players; foreach (TSPlayer tSPlayer in players) { if (tSPlayer != null && tSPlayer.Account != null) { DataBase.SrvPlayerUpdate(SrvPlayers[tSPlayer.Index]); } } Goals.ProgressUpdate(); }
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); }
private void PostInitialize(EventArgs args) { IsReload = true; Economy.Economy.Products = QueryShop.GetProducts(); TSPlayer.Server.SendInfoMessage("[Economy Shop] Pomyslnie zaladowano {0} produktow.", global::SurvivalCore.Economy.Economy.Products.Count); Goals.ProgressLoad(); IsReload = false; Thread thread = new Thread(OneSecondThread) { IsBackground = true }; thread.Start(); Thread thread2 = new Thread(EventThreadRun) { IsBackground = true }; thread2.Start(); Thread thread3 = new Thread(SaveThread) { IsBackground = true }; thread3.Start(); Thread thread4 = new Thread(PingThread) { IsBackground = true }; thread4.Start(); new Thread(GiveOutMoneyThread) { IsBackground = true }.Start(10); System.Timers.Timer task = new System.Timers.Timer(); task.Elapsed += BuffBoostTask; task.Interval = 3000; task.Enabled = true; }
protected override void Dispose(bool disposing) { if (disposing) { Goals.ProgressUpdate(); ServerApi.Hooks.GameInitialize.Deregister(this, global::SurvivalCore.Economy.Economy.OnInitialize); ServerApi.Hooks.WorldSave.Deregister(this, OnWorldSave); ServerApi.Hooks.NetGetData.Deregister(this, OnGetData); ServerApi.Hooks.ServerJoin.Deregister(this, OnJoin); ServerApi.Hooks.ServerLeave.Deregister(this, OnLeave); ServerApi.Hooks.ServerConnect.Deregister(this, OnConnect); ServerApi.Hooks.NetSendData.Deregister(this, OnSendData); AccountHooks.AccountCreate -= OnAccountC; AccountHooks.AccountDelete -= OnAccountD; PlayerHooks.PlayerPostLogin -= OnPlayerPostLogin; Hooks.Npc.PostUpdate -= NpcPostUpdate; } base.Dispose(disposing); }
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); }
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; } } }
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); }
private void OneSecondThread() { while (true) { try { while (true) { Thread.Sleep(1000); byte[] array = new byte[201]; foreach (int key2 in Guardians.Keys) { if ((DateTime.UtcNow - Guardians[key2]).TotalMilliseconds >= 5888.0) { Main.npc[key2].active = false; TSPlayer.All.SendData(PacketTypes.NpcUpdate, "", key2); array[key2] = (byte)key2; } } byte[] array2 = array; foreach (byte key in array2) { Guardians.Remove(key); } TSPlayer[] players = TShock.Players; Goal goal = Goals.GetCurrentGoal(); foreach (TSPlayer tSPlayer in players) { if (tSPlayer != null && tSPlayer.Account != null) { if (SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 0) && !IsStatusBusy[tSPlayer.Index]) { string text2 = string.Format("{7} [c/595959:───── «] [c/52e092:Powelder] [c/595959:» ───── ]{0}{1}{2}{3}{4}{5}{6} \n\r [c/595959:───── «] [c/52e092:Survival] [c/595959:» ───── ]", SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 1) //0 ? $"\n\r[c/66ff66:Online][c/595959::] {TShock.Utils.GetActivePlayerCount()}" : null, (!SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 7)) //1 ? null : (Ping.ContainsKey((byte)tSPlayer.Index) ? ("\n\r[c/66ff66:Ping][c/595959::] " + Ping[(byte)tSPlayer.Index]) : "\n\r[c/66ff66:Ping][c/595959::] -ms"), SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 2) //2 ? $"\n\r[c/66ff66:Konto][c/595959::] {SrvPlayers[tSPlayer.Index].Money:n0} {Economy.Economy.Config.ValueName}" : null, SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 3) //3 ? $"\n\r[c/66ff66:Zgony][c/595959::] {SrvPlayers[tSPlayer.Index].Deaths}" : null, SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 6) //4 ? $"\n\r[c/66ff66:PvP][c/595959::] {SrvPlayers[tSPlayer.Index].PvpKills}/{SrvPlayers[tSPlayer.Index].PvpDeaths} | {((SrvPlayers[tSPlayer.Index].PvpDeaths == 0) ? ((double) SrvPlayers[tSPlayer.Index].PvpKills) : Math.Round((double) SrvPlayers[tSPlayer.Index].PvpKills / (double) SrvPlayers[tSPlayer.Index].PvpDeaths, 2))}" : null, null, (!SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 5)) //5 ? null : $"\n\r[c/66ff66:{goal.Name}][c/595959::] {goal.Progress}/{goal.ToComplete} ({Math.Round((float)goal.Progress / (float)goal.ToComplete, 3) * 100}%)", RepeatLineBreaks(10) ); tSPlayer.SendData(PacketTypes.Status, text2, 0, 3); } } } } } catch (NullReferenceException) { } } }