Esempio n. 1
0
        public int AddCreateInventory(BinWriter w, bool isClient)
        {
            int numItems = 0;

            for (int i = 0; i <= (int)INVSLOT.EQUIPPEDFIRST; i++)
            {
                if (m_slots[i] != 0)
                {
                    m_invObjects[i].AddCreateObject(w, false, true);
                    numItems++;
                }
            }
            if (isClient)
            {
                for (int i = (int)INVSLOT.EQUIPPEDFIRST; i < (int)INVSLOT.NUM_INVENTORY_SLOTS; i++)//NUM_INVENTORY_SLOTS
                {
                    if (m_slots[i] == 0)
                    {
                        continue;
                    }
                    numItems++;
                    m_invObjects[i].AddCreateObject(w, false, true);
                    if (m_invObjects[i].ObjectType == OBJECTTYPE.CONTAINER)
                    {
                        ContainerObject container = m_invObjects[i] as ContainerObject;
                        for (int j = 0; j < container.Template.ContainerSlots; j++)
                        {
                            ItemObject item = container.Inventory[j];
                            if (item != null)
                            {
                                numItems++;
                                item.AddCreateObject(w, false, true);
                            }
                        }
                    }
                }
            }
            return(numItems);
        }
Esempio n. 2
0
        public ItemObject CreateItem(DBItem dbItem)
        {
            ItemObject item;

            if (dbItem.Template == null)
            {
                Console.WriteLine("DBItem " + dbItem.ObjectId + " is missing Item template on worldserver.");
                return(null);
            }
            if (dbItem.Template.InvType == INVTYPE.BAG)
            {
                item = new ContainerObject(dbItem, this);
            }
            else
            {
                item = new ItemObject(dbItem, this);
            }
            m_slots[dbItem.OwnerSlot]      = item.GUID;
            m_invObjects[dbItem.OwnerSlot] = item;
            m_owner.UpdateValue(m_baseField + dbItem.OwnerSlot * 2);
            m_itemCount++;
            return(item);
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
0
 public ContainerInventory(WorldObject owner) : base(owner, (int)CONTAINERFIELDS.SLOTS)
 {
     m_slots      = new ulong[20];
     m_invObjects = new ItemObject[20];
 }
Esempio n. 5
0
 public PlayerInventory(WorldObject owner) : base(owner, (int)PLAYERFIELDS.FIELD_INV_SLOT_HEAD)
 {
     m_slots      = new ulong[69];
     m_invObjects = new ItemObject[69];
 }