コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: QMain.cs プロジェクト: middas/TwitchysTShockPlugins
        public void OnGreetPlayer(int who, HandledEventArgs e)
        {
            QPlayer player = new QPlayer(who);

            lock (Players)
                Players.Add(player);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public AtXY(QPlayer player, int x, int y, int radius = 1)
 {
     this.player = player;
     this.x = x;
     this.y = y;
     this.radius = radius;
 }
コード例 #5
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);
        } //In Wiki
コード例 #6
0
        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));
        }
コード例 #7
0
ファイル: QTools.cs プロジェクト: Ijwu/TShock-Quest-System
 public static QuestAttemptData GetPlayerQuestData(string name, QPlayer Player)
 {
     foreach (QuestAttemptData data in Player.MyDBPlayer.QuestAttemptData)
     {
         if (data.QuestName == name)
             return data;
     }
     return null;
 }
コード例 #8
0
 public static string ReadNextChatLine(QPlayer Player, bool hide = false)
 {
     Player.AwaitingChat = true;
     Player.HideChat     = hide;
     while (Player.AwaitingChat)
     {
     }
     Player.HideChat = false;
     return(Player.LastChatMessage);
 }
コード例 #9
0
 public static QuestPlayerData GetPlayerQuestData(string name, QPlayer Player)
 {
     foreach (QuestPlayerData data in Player.MyDBPlayer.QuestPlayerData)
     {
         if (data.QuestName == name)
         {
             return(data);
         }
     }
     return(null);
 }
コード例 #10
0
 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
コード例 #11
0
        public static QPlayer GetPlayerByID(int id)
        {
            QPlayer player = null;

            foreach (QPlayer ply in QMain.Players)
            {
                if (ply.Index == id)
                {
                    return(ply);
                }
            }
            return(player);
        }
コード例 #12
0
        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);
            }
        }
コード例 #13
0
 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);
         }
     }
 }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
 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);
 }
コード例 #16
0
 public static void ClearKillList(QPlayer Player)
 {
     lock (Player.KillNames)
         Player.KillNames.Clear();
 }
コード例 #17
0
        } //In Wiki

        public static void StartQuest(string qname, QPlayer Player)
        {
            Player.NewQuest(QTools.GetQuestByName(qname), true);
        }
コード例 #18
0
 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;
 }
コード例 #19
0
 public MessagePlayer(string message, QPlayer player, Color color)
 {
     this.message = message;
     this.color = color;
     this.player = player;
 }
コード例 #20
0
 public GiveUpItem(QPlayer player, string type, int amount=1)
 {
     this.player = player;
     addItem(type, amount);
 }
コード例 #21
0
ファイル: QClasses.cs プロジェクト: Ijwu/TShock-Quest-System
 public Quest(QPlayer player, QuestInfo info)
 {
     this.player = player;
     this.info = info;
     LoadQuest();
 }
コード例 #22
0
 public BuffPlayer(QPlayer player, string buffname, int time)
 {
     this.player = player;
     this.buffname = buffname;
     this.time = time;
 }
コード例 #23
0
ファイル: QTools.cs プロジェクト: Ijwu/TShock-Quest-System
 public static StoredQPlayer GetStoredPlayerByIdentification(QPlayer player)
 {
     foreach (StoredQPlayer ply in QMain.LoadedPlayers)
     {
         if (ply.LoggedInName == player.TSPlayer.UserAccountName)
         {
             return ply;
         }
     }
     return null;
 }
コード例 #24
0
ファイル: QTools.cs プロジェクト: Ijwu/TShock-Quest-System
 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;
 }
コード例 #25
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);
 }
コード例 #26
0
 public RunQuestParameters(Quest quest, QPlayer player, Thread thread)
 {
     Quest   = quest;
     Player  = player;
     QThread = thread;
 }
コード例 #27
0
ファイル: QMain.cs プロジェクト: NanoPi/TwitchysTShockPlugins
        public void OnGreetPlayer(int who, HandledEventArgs e)
        {
            QPlayer player = new QPlayer(who);

            lock (Players)
                Players.Add(player);
        }
コード例 #28
0
 public static void Teleport(int x, int y, QPlayer Player)
 {
     Player.TSPlayer.Teleport(x, y + 3);
 }
コード例 #29
0
 public static void ClearKillList(QPlayer Player)
 {
     lock (Player.KillNames)
         Player.KillNames.Clear();
 }
コード例 #30
0
 public RunQuestParameters(Quest quest, QPlayer player, Thread thread)
 {
     Quest = quest;
     Player = player;
     QThread = thread;
 }
コード例 #31
0
 public Teleport(int x, int y, QPlayer player)
 {
     this.x = x;
     this.y = y;
     this.player = player;
 }
コード例 #32
0
 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;
     }
 }
コード例 #33
0
 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));
     }
 }
コード例 #34
0
 public static void Private(string message, QPlayer Player, Color color)
 {
     Player.TSPlayer.SendMessage(message, color);
 }
コード例 #35
0
        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.");
            }
        }
コード例 #36
0
 public static string ReadNextChatLine(QPlayer Player, bool hide = false)
 {
     Player.AwaitingChat = true;
     Player.HideChat = hide;
     while (Player.AwaitingChat) { }
     Player.HideChat = false;
     return Player.LastChatMessage;
 }
コード例 #37
0
 public HuntMob(QPlayer Player, string type, int amount=1)
 {
     player = Player;
     addNPC(type, amount);
 }
コード例 #38
0
 public static void StartQuest(string qname, QPlayer Player)
 {
     Player.NewQuest(QTools.GetQuestByName(qname), true);
 }
コード例 #39
0
 public ReadNextChatLine(QPlayer player, bool hideMsg = false)
 {
     this.player = player;
     this.hideMessage = hideMsg;
 }
コード例 #40
0
 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); }
     }
 }
コード例 #41
0
 public static void Teleport(int x, int y, QPlayer Player)
 {
     Player.TSPlayer.Teleport(x, y + 3);
 }
コード例 #42
0
        } //In Wiki

        public static void Private(string message, QPlayer Player, Color color)
        {
            Player.TSPlayer.SendMessage(message, color);
        } //In Wiki
コード例 #43
0
 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);
 }
コード例 #44
0
 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;
 }