Exemplo n.º 1
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;
            }
        }