private void SpawnMobs(Dictionary <string, int> mobs, ScPlayer sPly) { var mobList = new List <string>(); foreach (var pair in mobs) { var amount = Math.Min(pair.Value, Main.maxNPCs); var npcs = TShock.Utils.GetNPCByIdOrName(pair.Key); if (npcs.Count == 0) { continue; } if (npcs.Count > 1) { continue; } var npc = npcs[0]; if (npc.type >= 1 && npc.type < Main.maxNPCTypes && npc.type != 113) { TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, _point.X, _point.Y, 45, 18); mobList.Add(npc.name + "(" + amount + ")"); } else if (npc.type == 113) { if (Main.wof >= 0 || (_point.Y / 16f < (Main.maxTilesY - 205))) { continue; } NPC.SpawnWOF(new Vector2(_point.X, _point.Y)); mobList.Add("the Wall of Flesh (" + amount + ")"); } } sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", mobList)), Color.SteelBlue); /*TShock.Utils.SendLogs( * string.Format("{0} executed: {1}{2} [Via sign command].", sPly.TsPlayer.Name, * TShock.Config.CommandSpecifier, * "/spawnmob " + string.Join(", ", mobList)), Color.PaleVioletRed, sPly.TsPlayer);*/ }
private void SignCd(IList <string> args, ScPlayer player) { int cd; if (!int.TryParse(args[1], out cd)) { if (!player.TsPlayer.Group.HasPermission("sc.cdpass")) { if (SignCommands.config.CooldownGroups.ContainsKey(args[1])) { cd = SignCommands.config.CooldownGroups[args[1]]; _cooldownGroup = args[1]; } } else { cd = 0; } } _cooldown = cd; }
private void SpawnBoss(Dictionary <string, int> bosses, ScPlayer sPly) { int X = 50; int Y = 20; var bossList = new List <string>(); foreach (var pair in bosses) { //TSPlayer.Server.SpawnNPC(TShock.Utils.GetNPCById(num).type, TShock.Utils.GetNPCById(num).name, count, _point.X, _point.Y, X, Y);//for reference var npc = new NPC(); switch (pair.Key.ToLower()) { case "allboss": case "all": case "*": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn all bosses in daytime!"), Color.Crimson); return; } int[] allboss = { 4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370, 315, 325, 327, 344, 345, 346 }; foreach (var i in allboss) { npc.SetDefaults(i); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); } bossList.Add("all bosses(" + pair.Value + ")"); //sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", bossList)), Color.MediumPurple); break; case "normalboss": case "nmboss": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn normal bosses in daytime!"), Color.Crimson); return; } int[] nmboss = { 4, 35, 50, 222, 266 }; foreach (var i in nmboss) { npc.SetDefaults(i); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); } bossList.Add("normal bosses(" + pair.Value + ")"); //sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", bossList)), Color.MediumPurple); break; case "mechaboss": case "mcboss": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn mechanical 3 heads in daytime!"), Color.Crimson); return; } int[] mcboss = { 125, 126, 127, 134 }; foreach (var i in mcboss) { npc.SetDefaults(i); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); } bossList.Add("mechanical 3 heads(" + pair.Value + ")"); //sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", bossList)), Color.MediumPurple); break; case "hardboss": case "hmboss": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn hard bosses in daytime!"), Color.Crimson); return; } int[] hmboss = { 125, 126, 127, 134, 245, 262 }; foreach (var i in hmboss) { npc.SetDefaults(i); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); } bossList.Add("hardmode bosses(" + pair.Value + ")"); //sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", bossList)), Color.MediumPurple); break; case "pumpboss": case "pkboss": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn pmoon bosses in daytime!"), Color.Crimson); return; } int[] pkboss = { 315, 325, 328 }; foreach (var i in pkboss) { npc.SetDefaults(i); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); TSPlayer.Server.SpawnNPC(TShock.Utils.GetNPCById(315).type, TShock.Utils.GetNPCById(315).name, 1, _point.X, _point.Y, X, Y); //horseman } bossList.Add("pmoon bosses(" + pair.Value + ")"); //sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", bossList)), Color.MediumPurple); break; case "frozboss": case "fzboss": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn fmoon bosses in daytime!"), Color.Crimson); return; } int[] fzboss = { 344, 345, 346 }; foreach (var i in fzboss) { npc.SetDefaults(i); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); } bossList.Add("fmoon bosses(" + pair.Value + ")"); //sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", bossList)), Color.MediumPurple); break; case "slime": case "king slime": npc.SetDefaults(50); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, 45, 18); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "eye": case "eye of cthulhu": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn eye of cthulhu in daytime!"), Color.Crimson); return; } npc.SetDefaults(4); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "brain": case "brain of cthulhu": npc.SetDefaults(266); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "eater": case "eater of worlds": npc.SetDefaults(13); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, 55, 22); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "bee": case "queen bee": npc.SetDefaults(222); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "skeletron": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn skeletron in daytime!"), Color.Crimson); return; } npc.SetDefaults(35); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "wof": case "wall of flesh": if (Main.wof >= 0) { return; } if (_point.Y / 16f < Main.maxTilesY - 205) { break; } //TSPlayer.Server.SetTime(false, 0.0); NPC.SpawnWOF(new Vector2(_point.X, _point.Y)); bossList.Add("the Wall of Flesh(" + pair.Value + ")"); break; case "destroyer": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn destroyer in daytime!"), Color.Crimson); return; } npc.SetDefaults(134); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, 60, 24); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "twins": //TSPlayer.Server.SetTime(false, 0.0); if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn the twins in daytime!"), Color.Crimson); return; } npc.SetDefaults(125); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); npc.SetDefaults(126); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add("the Twins(" + pair.Value + ")"); break; case "prime": case "skeletron prime": if (Main.dayTime) { sPly.TsPlayer.SendMessage(String.Format("[Sign] You can't spawn skeletron prime in daytime!"), Color.Crimson); return; } npc.SetDefaults(127); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "golem": npc.SetDefaults(245); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, 45, 18); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "plantera": npc.SetDefaults(262); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add(npc.name + "(" + pair.Value + ")"); break; case "duke fishron": case "fishron": npc.SetDefaults(370); //TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y, X, Y); bossList.Add(npc.name + "(" + pair.Value + ")"); break; } } sPly.TsPlayer.SendMessage(String.Format("[Sign] You've spawned {0}", string.Join(", ", bossList)), Color.MediumPurple); /*TShock.Utils.SendLogs( * string.Format("{0} executed: {1}{2} [Via sign command].", sPly.TsPlayer.Name, * TShock.Config.CommandSpecifier, * "/spawnboss " + string.Join(", ", bossList)), Color.PaleVioletRed, sPly.TsPlayer);*/ }
public void ExecuteCommands(ScPlayer sPly) { var hasPerm = CheckPermissions(sPly.TsPlayer); if (!hasPerm) { return; } /*var overridePerm = CheckPermissionOverride(sPly.TsPlayer); * * if (!freeAccess && !hasPerm && !overridePerm) * { * if (sPly.AlertPermissionCooldown == 0) * { * sPly.TsPlayer.SendErrorMessage("You do not have access to the commands on this sign"); * sPly.AlertPermissionCooldown = 5; * } * return; * }*/ if (cooldown > 0) { if (sPly.AlertCooldownCooldown == 0) //&& !sPly.TsPlayer.Group.HasPermission("sc.alpass")) { sPly.TsPlayer.SendWarningMessage("[Sign] Still cooling down! {0} more second{1} left.", cooldown, cooldown.Suffix()); sPly.AlertCooldownCooldown = 2; } return; } /*if (cooldown > 0) * { * if (sPly.AlertCooldownCooldown == 0) * sPly.TsPlayer.SendErrorMessage("This sign is still cooling down. Please wait {0} more second{1}", * cooldown, cooldown.Suffix()); * * return; * }*/ if (_confirm && sPly.confirmSign != this) { sPly.confirmSign = this; sPly.TsPlayer.SendWarningMessage("[Warning] Hit the sign again to confirm."); cooldown = 1; return; } if (_groups.Count > 0 && !_groups.Contains(sPly.TsPlayer.Group.Name)) { if (sPly.AlertPermissionCooldown == 0) { sPly.TsPlayer.SendErrorMessage("Your group does not have access to this sign."); sPly.AlertPermissionCooldown = 2; } return; } if (_users.Count > 0 && !_users.Contains(sPly.TsPlayer.UserAccountName)) { if (sPly.AlertPermissionCooldown == 0) { sPly.TsPlayer.SendErrorMessage("You do not have access to this sign."); sPly.AlertPermissionCooldown = 2; } return; } if (_mobs.Count > 0) { /*{ * if (!sPly.TsPlayer.Group.HasPermission(Permissions.spawnmob)) * { * if (sPly.AlertPermissionCooldown == 0) * { * sPly.TsPlayer.SendErrorMessage("You do not have access to the commands on this sign"); * sPly.AlertPermissionCooldown = 5; * } * return; * }*/ SpawnMobs(_mobs, sPly); } //} if (_bosses.Count > 0) { /*{ * if (!sPly.TsPlayer.Group.HasPermission(Permissions.spawnboss)) * { * if (sPly.AlertPermissionCooldown == 0) * { * sPly.TsPlayer.SendErrorMessage("You do not have access to the commands on this sign"); * sPly.AlertPermissionCooldown = 5; * } * return; * }*/ SpawnBoss(_bosses, sPly); } //} foreach (var cmdPair in commands) { //var args = new List<string>(cmdPair.Key); var cmd = cmdPair.Value; var cmdText = string.Join(" ", cmdPair.Key); cmdText = cmdText.Replace("{player}", sPly.TsPlayer.Name); //Create args straight from the command text, meaning no need to iterate through args to replace {player} var args = cmdText.Split(' ').ToList(); //if (args.Any(s => s.Contains("{player}"))) // args[args.IndexOf("{player}")] = sPly.TsPlayer.Name; //while (args.Any(s => s.Contains("{player}"))) // args[args.IndexOf("{player}")] = sPly.TsPlayer.Name; if (cmd.DoLog) { TShock.Utils.SendLogs(string.Format("{0} executed: {1}{2} [Via sign command].", sPly.TsPlayer.Name, TShock.Config.CommandSpecifier, cmdText), Color.PaleVioletRed, sPly.TsPlayer); } args.RemoveAt(0); cmd.CommandDelegate.Invoke(new CommandArgs(cmdText, sPly.TsPlayer, args)); } cooldown = _cooldown; sPly.AlertCooldownCooldown = 2; sPly.confirmSign = null; }