Ejemplo n.º 1
0
        /// <summary>
        /// Add tok to player
        /// </summary>
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// <returns>True if command was correctly handled, false if operation was canceled</returns>
        public static bool AddTok(Player plr, ref List <string> values)
        {
            int tokEntry = GetInt(ref values);

            Tok_Info info = TokService.GetTok((ushort)tokEntry);

            if (info == null)
            {
                return(false);
            }

            plr = GetTargetOrMe(plr) as Player;
            plr.TokInterface.AddTok(info.Entry);

            GMCommandLog log = new GMCommandLog
            {
                PlayerName = plr.Name,
                AccountId  = (uint)plr.Client._Account.AccountId,
                Command    = "ADD TOK TO " + plr.Name + " " + tokEntry,
                Date       = DateTime.Now
            };

            CharMgr.Database.AddObject(log);

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set tok entry
        /// </summary>
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// <returns>True if command was correctly handled, false if operation was canceled</returns>
        public static bool ChapterTok(Player plr, ref List <string> values)
        {
            int entry    = GetInt(ref values);
            int tokEntry = GetInt(ref values);

            Chapter_Info chapter = ChapterService.GetChapter((ushort)entry);
            Tok_Info     tok     = TokService.GetTok((ushort)entry);

            if (tok == null || chapter == null)
            {
                return(false);
            }

            chapter.TokEntry = (ushort)tokEntry;
            chapter.Dirty    = true;
            WorldMgr.Database.SaveObject(chapter);

            return(true);
        }
Ejemplo n.º 3
0
        private void FixTokKills(ushort Entry)
        {
            Tok_Info Info = TokService.GetTok(Entry);

            if (Info == null)
            {
                return;
            }

            if (Info.Realm != 0 && Info.Realm != _Owner.GetPlayer().Info.Realm)
            {
                return;
            }

            Character_tok Tok = new Character_tok
            {
                TokEntry    = Entry,
                CharacterId = GetPlayer().CharacterId,
                Count       = 1
            };

            if (Tok == null)
            {
                return;
            }

            if (!HasTok(Entry))
            {
                SendTok(Entry, true);

                GetPlayer().AddXp(Info.Xp, false, false);

                _tokUnlocks.Add(Entry, Tok);

                GetPlayer().Info.Toks = _tokUnlocks.Values.ToList();

                CharMgr.Database.AddObject(Tok);
            }
        }
Ejemplo n.º 4
0
        public void FixTokItems()
        {
            //IList<Item_Info> tokItems = WorldMgr.Database.SelectObjects<Item_Info>("career=" + GetPlayer().Info.CareerFlags + " AND TokUnlock2 = " + item.Info.TokUnlock2);
            List <Item_Info> tokItems = new List <Item_Info>();

            for (ushort i = 10; i < 35; i++)
            {
                if (i != 29 && i != 30)
                {
                    Item item = GetPlayer().ItmInterface.GetItemInSlot(i);
                    if (item != null)
                    {
                        tokItems.Add(WorldMgr.Database.SelectObject <Item_Info>("entry =" + item.Info.Entry));
                    }
                }
            }

            foreach (Item_Info item in tokItems)
            {
                if (item != null && item.TokUnlock2 != 0 && !HasTok(item.TokUnlock2))
                {
                    IList <Item_Info> currentSet = WorldMgr.Database.SelectObjects <Item_Info>("career=" + GetPlayer().Info.CareerFlags + " AND TokUnlock2 = " + item.TokUnlock2);

                    int count = currentSet.Count();

                    foreach (Item_Info itm in currentSet)
                    {
                        if (count > 0)
                        {
                            foreach (Item_Info setItem in currentSet)
                            {
                                if (HasTok(setItem.TokUnlock))
                                {
                                    count--;
                                }
                            }
                        }

                        if (count == 0 && !HasTok(itm.TokUnlock2))
                        {
                            // Tok is send to player
                            SendTok((ushort)item.TokUnlock2, true);

                            Character_tok Tok2 = new Character_tok
                            {
                                TokEntry    = (ushort)item.TokUnlock2,
                                CharacterId = GetPlayer().CharacterId,
                                Count       = 1
                            };

                            Tok_Info InfoSetTok = TokService.GetTok((ushort)item.TokUnlock2);

                            // ToK is added to the book
                            _tokUnlocks.Add((ushort)item.TokUnlock2, Tok2);
                            GetPlayer().AddXp(InfoSetTok.Xp, false, false);

                            // Adding reward from final ToK - Title
                            SendTok((ushort)InfoSetTok.Rewards, true);

                            Character_tok Tok2Title = new Character_tok
                            {
                                TokEntry    = (ushort)InfoSetTok.Rewards,
                                CharacterId = GetPlayer().CharacterId,
                                Count       = 1
                            };

                            Tok_Info TokInfoTitle = TokService.GetTok((ushort)InfoSetTok.Rewards);

                            _tokUnlocks.Add((ushort)InfoSetTok.Rewards, Tok2Title);
                            GetPlayer().AddXp(TokInfoTitle.Xp, false, false);

                            // ToKs saved in DB :)
                            CharMgr.Database.AddObject(Tok2);
                            CharMgr.Database.AddObject(Tok2Title);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void CheckTokKills(ushort type, uint count)
        {
            Tok_Bestary TB = TokService.GetTokBestary(type);

            if (TB == null)
            {
                return;
            }

            uint kill = count;

            string tok;

            if (kill >= 1 && TB.Kill1 != null)
            {
                tok = TB.Kill1;
                string[] tmp = tok.Split(';');
                if (tmp.Length > 0)
                {
                    foreach (string st in tmp)
                    {
                        FixTokKills(UInt16.Parse(st));
                    }
                }
                else
                {
                    FixTokKills(UInt16.Parse(tok));
                }
            }

            if (kill >= 25 && TB.Kill25 != null)
            {
                tok = TB.Kill25;
                string[] tmp = tok.Split(';');
                if (tmp.Length > 0)
                {
                    foreach (string st in tmp)
                    {
                        FixTokKills(UInt16.Parse(st));
                    }
                }
                else
                {
                    FixTokKills(UInt16.Parse(tok));
                }
            }

            if (kill >= 100 && TB.Kill100 != null)
            {
                tok = TB.Kill100;
                string[] tmp = tok.Split(';');
                if (tmp.Length > 0)
                {
                    foreach (string st in tmp)
                    {
                        FixTokKills(UInt16.Parse(st));
                    }
                }
                else
                {
                    FixTokKills(UInt16.Parse(tok));
                }
            }

            if (kill >= 1000 && TB.Kill1000 != null)
            {
                tok = TB.Kill1000;
                string[] tmp = tok.Split(';');
                if (tmp.Length > 0)
                {
                    foreach (string st in tmp)
                    {
                        FixTokKills(UInt16.Parse(st));
                    }
                }
                else
                {
                    FixTokKills(UInt16.Parse(tok));
                }
            }

            if (kill >= 10000 && TB.Kill10000 != null)
            {
                tok = TB.Kill10000;
                string[] tmp = tok.Split(';');
                if (tmp.Length > 0)
                {
                    foreach (string st in tmp)
                    {
                        FixTokKills(UInt16.Parse(st));
                    }
                }
                else
                {
                    FixTokKills(UInt16.Parse(tok));
                }
            }

            if (kill >= 100000 && TB.Kill100000 != null)
            {
                tok = TB.Kill100000;
                string[] tmp = tok.Split(';');
                if (tmp.Length > 0)
                {
                    foreach (string st in tmp)
                    {
                        FixTokKills(UInt16.Parse(st));
                    }
                }
                else
                {
                    FixTokKills(UInt16.Parse(tok));
                }
            }
        }
Ejemplo n.º 6
0
        public void AddKill(ushort type)
        {
            Tok_Bestary TB = TokService.GetTokBestary(type);

            if (TB == null)
            {
                return;
            }

            Character_tok_kills kills;

            if (_tokKillCount.TryGetValue(TB.Bestary_ID, out kills))
            {
                kills.Count++;
                kills.Dirty = true;
                CharMgr.Database.SaveObject(kills);
            }

            else
            {
                kills = new Character_tok_kills
                {
                    NPCEntry    = TB.Bestary_ID,
                    CharacterId = GetPlayer().CharacterId,
                    Count       = 1
                };
                _tokKillCount.Add(TB.Bestary_ID, kills);
                GetPlayer().Info.TokKills = _tokKillCount.Values.ToList();
                CharMgr.Database.AddObject(kills);
            }
            uint kill = kills.Count;

            //Log.Info("creature type", "" + type+"  bestid "+ TB.Bestary_ID + " kills "+ kill);

            SendActionCounterUpdate(TB.Bestary_ID, kill);

            // total kill counter

            if (_tokKillCount.TryGetValue(495, out kills))
            {
                kills.Count++;
                kills.Dirty = true;
                CharMgr.Database.SaveObject(kills);
            }
            SendActionCounterUpdate(495, kills.Count);

            string tok;

            if (kill == 100000 && TB.Kill100000 != null)
            {
                tok = TB.Kill100000;
            }
            else if (kill == 10000 && TB.Kill10000 != null)
            {
                tok = TB.Kill10000;
            }
            else if (kill == 1000 && TB.Kill1000 != null)
            {
                tok = TB.Kill1000;
            }
            else if (kill == 100 && TB.Kill100 != null)
            {
                tok = TB.Kill100;
            }
            else if (kill == 25 && TB.Kill25 != null)
            {
                tok = TB.Kill25;
            }
            else if (kill == 1 && TB.Kill1 != null)
            {
                tok = TB.Kill1;
            }
            else
            {
                return;
            }

            string[] tmp = tok.Split(';');
            if (tmp.Length > 0)
            {
                foreach (string st in tmp)
                {
                    AddTok(UInt16.Parse(st));
                }
            }
            else
            {
                AddTok(UInt16.Parse(tok));
            }
        }
Ejemplo n.º 7
0
        // variable itemEquipedToK checks if this ToK was triggered by equiping item. If it is true it was, otherwise it is false
        public void AddTok(ushort Entry, bool itemEquipedToK = false)
        {
            if (HasTok(Entry))
            {
                return;
            }

            if (!_loaded)
            {
                Log.Error("ToKSystem", "Tried to add ToK when system wasn't loaded.\n" + Environment.StackTrace);
                return;
            }

            Tok_Info Info = TokService.GetTok(Entry);

            if (Info == null)
            {
                return;
            }

            if (Info.Realm != 0 && Info.Realm != _Owner.GetPlayer().Info.Realm)
            {
                return;
            }


            SendTok(Entry, true);

            Character_tok Tok = new Character_tok
            {
                TokEntry    = Entry,
                CharacterId = GetPlayer().CharacterId,
                Count       = 1
            };

            _tokUnlocks.Add(Entry, Tok);
            GetPlayer().AddXp(Info.Xp, false, false);

            // This checks if ToK we are adding is a part of larger ToK, for example title
            // "Sovereign Trinket" is part of title "The Sovereign"
            if (itemEquipedToK)
            {
                // Selects item we equiped from DB
                Item_Info tokItemUnlock2 = WorldMgr.Database.SelectObject <Item_Info>("career=" + GetPlayer().Info.CareerFlags + " AND TokUnlock=" + Entry);

                if (tokItemUnlock2 != null && tokItemUnlock2.TokUnlock != 0 && tokItemUnlock2.TokUnlock2 != 0)
                {
                    // Selects secondary ToK we want to setup if we completed full set
                    IList <Item_Info> tokItems = WorldMgr.Database.SelectObjects <Item_Info>("career=" + GetPlayer().Info.CareerFlags + " AND TokUnlock2 = " + tokItemUnlock2.TokUnlock2);
                    int count = tokItems.Count();

                    // If there is more than 0 items with complete set unlock we proceed
                    if (count > 0)
                    {
                        foreach (Item_Info tokItem in tokItems)
                        {
                            if (HasTok(tokItem.TokUnlock))
                            {
                                count--;
                            }
                        }
                        // If we have all required unlocks count = 0 and we can proceed
                        if (count == 0)
                        {
                            // Tok is send to player
                            SendTok((ushort)tokItemUnlock2.TokUnlock2, true);

                            Character_tok Tok2 = new Character_tok
                            {
                                TokEntry    = (ushort)tokItemUnlock2.TokUnlock2,
                                CharacterId = GetPlayer().CharacterId,
                                Count       = 1
                            };

                            Tok_Info InfoSetTok = TokService.GetTok((ushort)tokItemUnlock2.TokUnlock2);

                            // ToK is added to the book
                            _tokUnlocks.Add((ushort)tokItemUnlock2.TokUnlock2, Tok2);
                            GetPlayer().AddXp(InfoSetTok.Xp, false, false);

                            // Adding reward from final ToK - Title
                            SendTok((ushort)InfoSetTok.Rewards, true);

                            Character_tok Tok2Title = new Character_tok
                            {
                                TokEntry    = (ushort)InfoSetTok.Rewards,
                                CharacterId = GetPlayer().CharacterId,
                                Count       = 1
                            };

                            Tok_Info TokInfoTitle = TokService.GetTok((ushort)InfoSetTok.Rewards);

                            _tokUnlocks.Add((ushort)InfoSetTok.Rewards, Tok2Title);
                            GetPlayer().AddXp(TokInfoTitle.Xp, false, false);

                            //ToKs saved in DB :)
                            CharMgr.Database.AddObject(Tok2);
                            CharMgr.Database.AddObject(Tok2Title);
                        }
                    }
                }
            }

            if (Info.Rewards > 0)
            {
                // this will be used for future additions like the tome tactics and gear to buy
                if (Info.Rewards == 1)
                {
                    GetPlayer().ItmInterface.CreateItem(80001, 1);   // Betial Token
                }
            }

            GetPlayer().Info.Toks = _tokUnlocks.Values.ToList();

            CharMgr.Database.AddObject(Tok);
        }