public static bool AtXY(int x, int y, QPlayer Player, int radius = 1) { Rectangle rec, playerrec; rec = new Rectangle(x - radius, y - radius, radius * 2, radius * 2); playerrec = new Rectangle((int)Player.TSPlayer.X / 16, (int)Player.TSPlayer.Y / 16, 1, 1); return rec.Intersects(playerrec); }
public void OnGreetPlayer(int who, HandledEventArgs e) { QPlayer player = new QPlayer(who); lock (Players) Players.Add(player); }
public static void GoCollectItem(string name, int amount, QPlayer Player) { int count; do { count = 0; try { foreach (Item slot in Player.Inventory) { if (slot != null) { if (slot.name.ToLower() == name.ToLower()) { count += slot.stack; } } } } catch (Exception e) { Log.Info(e.Message); } Thread.Sleep(1); }while (count < amount); }
public AtXY(QPlayer player, int x, int y, int radius = 1) { this.player = player; this.x = x; this.y = y; this.radius = radius; }
//Below = New in V1.2 //Fixed/Working public static void Give(string name, QPlayer Player, int amount = 1) { Main.rand = new Random(); Item item = TShock.Utils.GetItemByName(name)[0]; Player.TSPlayer.GiveItem(item.type, item.name, item.width, item.height, amount); } //In Wiki
public static bool AtXY(int x, int y, QPlayer Player, int radius = 1) { Rectangle rec, playerrec; rec = new Rectangle(x - radius, y - radius, radius * 2, radius * 2); playerrec = new Rectangle((int)Player.TSPlayer.X / 16, (int)Player.TSPlayer.Y / 16, 1, 1); return(rec.Intersects(playerrec)); }
public static QuestAttemptData GetPlayerQuestData(string name, QPlayer Player) { foreach (QuestAttemptData data in Player.MyDBPlayer.QuestAttemptData) { if (data.QuestName == name) return data; } return null; }
public static string ReadNextChatLine(QPlayer Player, bool hide = false) { Player.AwaitingChat = true; Player.HideChat = hide; while (Player.AwaitingChat) { } Player.HideChat = false; return(Player.LastChatMessage); }
public static QuestPlayerData GetPlayerQuestData(string name, QPlayer Player) { foreach (QuestPlayerData data in Player.MyDBPlayer.QuestPlayerData) { if (data.QuestName == name) { return(data); } } return(null); }
public static void Kill(string name, QPlayer Player, int amount = 1) { for (int i = 0; i < amount; i++) { Player.AwaitingKill = true; while (!Player.KillNames.Contains(name)) { Thread.Sleep(1); } Player.KillNames.Remove(name); Player.AwaitingKill = false; } } //In Wiki
public static QPlayer GetPlayerByID(int id) { QPlayer player = null; foreach (QPlayer ply in QMain.Players) { if (ply.Index == id) { return(ply); } } return(player); }
public static void StartQuest(CommandArgs args) { QPlayer Player = QTools.GetPlayerByID(args.Player.Index); if (Player.IsLoggedIn) { Rectangle ply = new Rectangle((int)args.Player.X / 16, (int)args.Player.Y / 16, 1, 1); bool questfound = false; foreach (QuestRegion qr in QMain.QuestRegions) { if (ply.Intersects(qr.Area)) { foreach (Quest q in qr.Quests) { QuestPlayerData data = QTools.GetPlayerQuestData(q.Name, Player); if (QTools.AbleToRunQuest(q) && (q.MinQuestsNeeded == 0 || q.MinQuestsNeeded <= QTools.GetQuestsCompleted(Player.MyDBPlayer.QuestPlayerData)) && q.Name.ToLower() == args.Parameters[0].ToLower() && (q.MaxAttemps == 0 || data == null || QTools.GetPlayerQuestData(q.Name, Player).Attempts < q.MaxAttemps)) { questfound = true; break; } } } if (questfound) { break; } } if (questfound) { if (!Player.NewQuest(QTools.GetQuestByName(args.Parameters[0]))) { Player.TSPlayer.SendMessage("Quest already running.", Color.Red); } } else { Player.TSPlayer.SendMessage("Quest not found.", Color.Red); } } else { Player.TSPlayer.SendMessage("You are not Logged in", Color.Red); } }
public static void TakeItem(string qname, string iname, int amt, QPlayer Player) { if (amt > 0) { var aitem = new AwaitingItem(qname, amt, iname); Player.AwaitingItems.Add(aitem); if (amt > 1) { Player.TSPlayer.SendMessage(string.Format("Please drop {0} {1}'s, The excess will be returned.", amt, iname)); } else { Player.TSPlayer.SendMessage(string.Format("Please drop {0} {1}, The excess will be returned.", amt, iname)); } while (Player.AwaitingItems.Contains(aitem)) { Thread.Sleep(1); } } }
public static void ListQuest(CommandArgs args) { QPlayer Player = QTools.GetPlayerByID(args.Player.Index); if (Player.IsLoggedIn) { Rectangle ply = new Rectangle((int)args.Player.X / 16, (int)args.Player.Y / 16, 1, 1); string availquests = "Available Quests: "; foreach (QuestRegion qr in QMain.QuestRegions) { if (ply.Intersects(qr.Area)) { foreach (Quest q in qr.Quests) { QuestPlayerData data = QTools.GetPlayerQuestData(q.Name, Player); if (QTools.AbleToRunQuest(q) && (q.MinQuestsNeeded == 0 || q.MinQuestsNeeded <= QTools.GetQuestsCompleted(Player.MyDBPlayer.QuestPlayerData)) && (q.MaxAttemps == 0 || data == null || QTools.GetPlayerQuestData(q.Name, Player).Attempts < q.MaxAttemps)) { availquests = availquests + q.Name + ", "; } } } } if (availquests != "Available Quests: ") { availquests = availquests.Substring(0, availquests.Length - 2); Player.TSPlayer.SendMessage(availquests, Color.Magenta); Player.TSPlayer.SendMessage("Use /startquest [Quest Name], to begin that quest", Color.Magenta); } else { Player.TSPlayer.SendMessage("No Available Quests", Color.Red); } } else { Player.TSPlayer.SendMessage("You are not Logged in", Color.Red); } }
public static StoredQPlayer GetStoredPlayerByIdentification(QPlayer Player) { if (Player.TSPlayer.IsLoggedIn) { for (int i = 0; i < QMain.StoredPlayers.Count; i++) { if (QMain.StoredPlayers[i].LoggedInName == Player.TSPlayer.UserAccountName) { return(QMain.StoredPlayers[i]); } } } else { for (int i = 0; i < QMain.StoredPlayers.Count; i++) { if (QMain.StoredPlayers[i].LoggedInName == Player.TSPlayer.IP) { return(QMain.StoredPlayers[i]); } } } return(null); }
public static void ClearKillList(QPlayer Player) { lock (Player.KillNames) Player.KillNames.Clear(); }
} //In Wiki public static void StartQuest(string qname, QPlayer Player) { Player.NewQuest(QTools.GetQuestByName(qname), true); }
public Reward(QPlayer player, string item, int stack=1, int prefix=0) { List<Item> items = TShock.Utils.GetItemByIdOrName(item); if (items.Count == 1) { this.item = items[0]; this.player = player; } else { throw new FormatException("More than one or no items matched to name or ID."); } this.item.prefix = (byte)prefix; this.item.stack = stack; }
public MessagePlayer(string message, QPlayer player, Color color) { this.message = message; this.color = color; this.player = player; }
public GiveUpItem(QPlayer player, string type, int amount=1) { this.player = player; addItem(type, amount); }
public Quest(QPlayer player, QuestInfo info) { this.player = player; this.info = info; LoadQuest(); }
public BuffPlayer(QPlayer player, string buffname, int time) { this.player = player; this.buffname = buffname; this.time = time; }
public static StoredQPlayer GetStoredPlayerByIdentification(QPlayer player) { foreach (StoredQPlayer ply in QMain.LoadedPlayers) { if (ply.LoggedInName == player.TSPlayer.UserAccountName) { return ply; } } return null; }
public static int IntervalLeft(QPlayer player, QuestInfo q) { foreach (QuestAttemptData info in player.MyDBPlayer.QuestAttemptData) { if (info.QuestName == q.Name) { return DateTime.UtcNow.Subtract(info.LastAttempt) > q.Interval ? 0 : q.Interval.Seconds - DateTime.UtcNow.Subtract(info.LastAttempt).Seconds; } } return 0; }
//Below = New in V1.2 //Fixed/Working public static void Give(string name, QPlayer Player, int amount = 1) { Main.rand = new Random(); Item item = TShock.Utils.GetItemByName(name)[0]; Player.TSPlayer.GiveItem(item.type, item.name, item.width, item.height, amount); }
public RunQuestParameters(Quest quest, QPlayer player, Thread thread) { Quest = quest; Player = player; QThread = thread; }
public static void Teleport(int x, int y, QPlayer Player) { Player.TSPlayer.Teleport(x, y + 3); }
public Teleport(int x, int y, QPlayer player) { this.x = x; this.y = y; this.player = player; }
public static void Kill(string name, QPlayer Player, int amount = 1) { for (int i = 0; i < amount; i++) { Player.AwaitingKill = true; while (!Player.KillNames.Contains(name)) { Thread.Sleep(1); } Player.KillNames.Remove(name); Player.AwaitingKill = false; } }
public ChangePlayerGroup(QPlayer player, string targetGroup) { this.player = player.TSPlayer; if (TShock.Groups.GroupExists(targetGroup)) { this.targetGroup = targetGroup; } else { throw new FormatException(string.Format("The group {0} does not exist.", targetGroup)); } }
public static void Private(string message, QPlayer Player, Color color) { Player.TSPlayer.SendMessage(message, color); }
public GatherItem(QPlayer player, string item, int amount=1) { this.player = player; this.amount = amount; List<Item> items = TShock.Utils.GetItemByIdOrName(item); if (items.Count == 1) { this.item = items[0]; foreach(Item slot in player.Inventory) { if (slot != null) if (slot.name.ToLower() == this.item.name.ToLower()) count -= slot.stack; } } else { throw new FormatException("More than one or no items matched to name or ID."); } }
public static string ReadNextChatLine(QPlayer Player, bool hide = false) { Player.AwaitingChat = true; Player.HideChat = hide; while (Player.AwaitingChat) { } Player.HideChat = false; return Player.LastChatMessage; }
public HuntMob(QPlayer Player, string type, int amount=1) { player = Player; addNPC(type, amount); }
public static void StartQuest(string qname, QPlayer Player) { Player.NewQuest(QTools.GetQuestByName(qname), true); }
public ReadNextChatLine(QPlayer player, bool hideMsg = false) { this.player = player; this.hideMessage = hideMsg; }
public static void TakeItem(string qname, string iname, int amt, QPlayer Player) { if (amt > 0) { var aitem = new AwaitingItem(qname, amt, iname); Player.AwaitingItems.Add(aitem); if (amt > 1) Player.TSPlayer.SendMessage(string.Format("Please drop {0} {1}'s, The excess will be returned.", amt, iname)); else Player.TSPlayer.SendMessage(string.Format("Please drop {0} {1}, The excess will be returned.", amt, iname)); while (Player.AwaitingItems.Contains(aitem)) { Thread.Sleep(1); } } }
} //In Wiki public static void Private(string message, QPlayer Player, Color color) { Player.TSPlayer.SendMessage(message, color); } //In Wiki
public static void GoCollectItem(string name, int amount, QPlayer Player) { int count; do { count = 0; try { foreach (Item slot in Player.Inventory) { if (slot != null) if (slot.name.ToLower() == name.ToLower()) count += slot.stack; } } catch (Exception e) { Log.Info(e.Message); } Thread.Sleep(1); } while (count < amount); }
public static StoredQPlayer GetStoredPlayerByIdentification(QPlayer Player) { if (Player.TSPlayer.IsLoggedIn) { for (int i = 0; i < QMain.StoredPlayers.Count; i++) if (QMain.StoredPlayers[i].LoggedInName == Player.TSPlayer.UserAccountName) return QMain.StoredPlayers[i]; } else { for (int i = 0; i < QMain.StoredPlayers.Count; i++) if (QMain.StoredPlayers[i].LoggedInName == Player.TSPlayer.IP) return QMain.StoredPlayers[i]; } return null; }