/// <summary> /// Increases age by years and sends update packets. /// </summary> /// <param name="years"></param> public void AgeUp(short years) { if (years < 0 || this.Age + years > short.MaxValue) { return; } float life = 0, mana = 0, stamina = 0, str = 0, dex = 0, int_ = 0, will = 0, luck = 0; short ap = 0; var newAge = this.Age + years; while (this.Age < newAge) { // Increase age before requestin statUp, we want the stats // for the next age. this.Age++; var statUp = AuraData.StatsAgeUpDb.Find(this.Race, this.Age); if (statUp == null) { // Continue silently, creatures age past 25 without // bonuses, and if someone changes that we don't know what // the max will be. //Log.Debug("AgeUp: Missing stat data for race '{0}', age '{1}'.", this.Race, this.Age); continue; } // Collect bonuses for multi aging life += statUp.Life; mana += statUp.Mana; stamina += statUp.Stamina; str += statUp.Str; dex += statUp.Dex; int_ += statUp.Int; will += statUp.Will; luck += statUp.Luck; ap += statUp.AP; } // Apply stat bonuses this.LifeMaxBase += life; this.Life += life; this.ManaMaxBase += mana; this.Mana += mana; this.StaminaMaxBase += stamina; this.Stamina += stamina; this.StrBase += str; this.DexBase += dex; this.IntBase += int_; this.WillBase += will; this.LuckBase += luck; this.AbilityPoints += ap; this.LastAging = DateTime.Now; if (this is Character) { this.Height = Math.Min(1.0f, 1.0f / 7.0f * (this.Age - 10.0f)); // 0 ~ 1.0 } // Send stat bonuses if (life != 0) { Send.SimpleAcquireInfo(this, "life", mana); } if (mana != 0) { Send.SimpleAcquireInfo(this, "mana", mana); } if (stamina != 0) { Send.SimpleAcquireInfo(this, "stamina", stamina); } if (str != 0) { Send.SimpleAcquireInfo(this, "str", str); } if (dex != 0) { Send.SimpleAcquireInfo(this, "dex", dex); } if (int_ != 0) { Send.SimpleAcquireInfo(this, "int", int_); } if (will != 0) { Send.SimpleAcquireInfo(this, "will", will); } if (luck != 0) { Send.SimpleAcquireInfo(this, "luck", luck); } if (ap != 0) { Send.SimpleAcquireInfo(this, "ap", ap); } Send.StatUpdateDefault(this); // XXX: Replace with effect and notice to allow something to happen past age 25? Send.AgeUpEffect(this, this.Age); }