Exemplo n.º 1
0
        public void AddTok(UInt32 Entry)
        {
            if (HasTok(Entry))
            {
                return;
            }

            Tok_Info Info = WorldMgr.GetTok(Entry);

            if (Info == null)
            {
                return;
            }

            SendTok(Entry, true);

            Character_tok Tok = new Character_tok();

            Tok.TokEntry    = Entry;
            Tok.CharacterId = GetPlayer().CharacterId;
            Tok.Count       = 1;
            Tok.Dirty       = true;

            _Toks.Add(Entry, Tok);
            GetPlayer().AddXp(Info.Xp);
            GetPlayer()._Info.Toks = _Toks.Values.ToArray();

            CharMgr.Database.AddObject(Tok);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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);
        }