Exemplo n.º 1
0
 public void Send(DBItemTemplate template)
 {
     if (m_hasItemTemplate[(int)template.ObjectId])
     {
         return;
     }
     m_hasItemTemplate[(int)template.ObjectId] = true;
     SendDBObject(template);
 }
Exemplo n.º 2
0
        static bool OnvAddItem(LoginClient client, string input)
        {
            if (client.Account.AccessLvl < ACCESSLEVEL.GM)
            {
                Chat.System(client, "You do not have access to this command");
                return(true);
            }

            string[] split = input.Split(' ');
            if (split.Length < 3)
            {
                return(false);
            }
            DBVendorItem item = new DBVendorItem();

            DataObject[] obj = DataServer.Database.SelectObjects(typeof(DBVendor), "GUID='" + client.Character.Selected + "'");
            if (obj == null || obj.Length == 0)
            {
                Chat.System(client, "Vendor not found");
                return(true);
            }
            DBVendor vendor = (DBVendor)obj[0];

            item.VendorID = vendor.ObjectId;

            item.TemplateID = (uint)int.Parse(split[1]);
            DBItemTemplate template = (DBItemTemplate)DataServer.Database.FindObjectByKey(typeof(DBItemTemplate), item.TemplateID);

            if (template == null)
            {
                Chat.System(client, "Item template not found for " + item.TemplateID);
                item = null;
                return(false);
            }
            item.CurrentQty = int.Parse(split[2]);
            if (split.Length > 3)
            {
                item.Price = int.Parse(split[3]);
            }
            else if (template.BuyPrice > 0)
            {
                item.Price = template.BuyPrice;
            }
            else
            {
                item.Price = (int)10;
            }
            DataServer.Database.AddNewObject(item);
            DataServer.Database.SaveObject(item);
            Chat.System(client, "Added item " + template.Name + " to vendor " + vendor.Name);
            DataServer.Database.FillObjectRelations(vendor);
            DataServer.Database.FillObjectRelations(item);

            return(true);
        }
Exemplo n.º 3
0
 public ItemObject(DBItem item, ObjectInventory inventory)
 {
     m_guid     = ObjectManager.NextGUID();
     m_itemData = item;
     m_template = item.Template;
     if (m_itemData.ObjectId == 0)
     {
         DBManager.CreateDBObject(m_itemData);
     }
     m_containedIn = inventory;
     ObjectManager.AddWorldObject(this);
 }
        static bool OnItemQuerySingle(LoginClient client, CMSG msgID, BinReader data)
        {
            uint           id       = data.ReadUInt32();
            DBItemTemplate template = (DBItemTemplate)DataServer.Database.FindObjectByKey(typeof(DBItemTemplate), id);

            if (template == null)
            {
                Console.WriteLine("Client requested an item template that didn't exist:" + id);
                return(true);
            }
            BinWriter w = LoginClient.NewPacket(SMSG.ITEM_QUERY_SINGLE_RESPONSE);

            w.Write(id);
            foreach (SerializeValue value in itemTemplateValues)
            {
                value.Serialize(template, w);
            }
            client.Send(w);
            return(true);
        }
Exemplo n.º 5
0
        static bool OnGiveitem(LoginClient client, string input)
        {
            if (client.Account.AccessLvl < ACCESSLEVEL.GM)
            {
                Chat.System(client, "You do not have access to this command");
                return(true);
            }

            string[] split = input.Split(' ');
            if (split.Length < 2)
            {
                return(false);
            }
            uint           templateId = (uint)int.Parse(split[1]);
            DBItemTemplate template   = (DBItemTemplate)DataServer.Database.FindObjectByKey(typeof(DBItemTemplate), templateId);

            if (!(template == null))
            {
                DBItem newItem = new DBItem();
                newItem.OwnerID    = client.Character.ObjectId;
                newItem.OwnerSlot  = 0;
                newItem.TemplateID = templateId;
                newItem.Template   = template;
                DataServer.Database.AddNewObject(newItem);
                client.WorldConnection.Send(newItem);

                ScriptPacket Item = new ScriptPacket(SCRMSG.BUYITEM);

                Item.Write(client.Character.ObjectId);
                Item.Write(newItem.ObjectId);
                Item.Write((int)0);
                client.WorldConnection.Send(Item);
                return(true);
            }
            Chat.System(client, "Item not found");
            return(true);
        }
Exemplo n.º 6
0
        public static void CalculateInvStats(PlayerObject pobj)
        {
            int   physical       = 0;
            int   holy           = 0;
            int   fire           = 0;
            int   nature         = 0;
            int   frost          = 0;
            int   shadow         = 0;
            int   strength       = 0;
            int   agility        = 0;
            int   stamina        = 0;
            int   intellect      = 0;
            int   spirit         = 0;
            int   health         = 0;
            int   power          = 0;
            float mindamage      = 2.0f;
            float maxdamage      = 4.0f;
            int   baseattacktime = 2000;

            for (int i = 0; i < 18; i++)
            {
                ItemObject item = pobj.Inventory[i];
                if (item != null && item.Template != null)
                {
                    DBItemTemplate template = item.Template;
                    physical += template.Resists.Physical;
                    holy     += template.Resists.Holy;
                    fire     += template.Resists.Fire;
                    nature   += template.Resists.Nature;
                    frost    += template.Resists.Frost;
                    shadow   += template.Resists.Shadow;
                    for (int bonus = 0; bonus < 10; bonus++)
                    {
                        ItemBonus itembonus = template.getItemBonus(bonus);
                        if (itembonus.Stat >= 0 && itembonus.Bonus != 0)
                        {
                            Console.WriteLine("itembonusstat: " + itembonus.Stat);
                            Console.WriteLine("itembonusstatbonus: " + itembonus.Bonus);

                            if (itembonus.Stat == 0)
                            {
                                power += itembonus.Bonus;
                            }
                            else if (itembonus.Stat == 1)
                            {
                                health += itembonus.Bonus;
                            }
                            else if (itembonus.Stat == 3)
                            {
                                agility += itembonus.Bonus;
                            }
                            else if (itembonus.Stat == 4)
                            {
                                strength += itembonus.Bonus;
                            }
                            else if (itembonus.Stat == 5)
                            {
                                intellect += itembonus.Bonus;
                            }
                            else if (itembonus.Stat == 6)
                            {
                                spirit += itembonus.Bonus;
                            }
                            else if (itembonus.Stat == 7)
                            {
                                stamina += itembonus.Bonus;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (i == (int)INVSLOT.MAINHAND)
                    {
                        DamageStat damagestat = template.getDamageStat(0);
                        mindamage      = (float)damagestat.Min;
                        maxdamage      = (float)damagestat.Max;
                        baseattacktime = template.WeaponSpeed;
                    }

                    if (i == (int)INVSLOT.OFFHAND)
                    {
                        if (template.SubClass == 5 || template.SubClass == 6)
                        {
                            pobj.HasShield = true;
                        }
                        else
                        {
                            pobj.HasShield = false;
                        }
                    }
                }
            }

            pobj.MaxHealth += health;
            pobj.MaxPower  += power;

            pobj.MaxHealth += (stamina * 10);
            pobj.MaxPower  += (intellect * 10);

            pobj.BaseStrength += strength;

            pobj.BaseStamina += stamina;

            pobj.BaseAgility += agility;

            pobj.BaseIntellect += intellect;

            pobj.BaseSpirit += spirit;

            pobj.Resist_Physical = physical;
            pobj.Resist_Holy     = holy;
            pobj.Resist_Fire     = fire;
            pobj.Resist_Nature   = nature;
            pobj.Resist_Frost    = frost;
            pobj.Resist_Shadow   = shadow;

            pobj.MinDamage      = mindamage;
            pobj.MaxDamage      = maxdamage;
            pobj.BaseAttackTime = baseattacktime;            //baseattacktime;

            if (pobj.Health > pobj.MaxHealth)
            {
                pobj.Health = pobj.MaxHealth;
            }
            if (pobj.Power > pobj.MaxPower)
            {
                pobj.Power = pobj.MaxPower;
            }
        }
Exemplo n.º 7
0
 public void Resend(DBItemTemplate template)
 {
     m_hasItemTemplate[(int)template.ObjectId] = true;
     SendDBObject(template);
 }