GiveExp() public method

Increases exp and levels up creature if appropriate.
public GiveExp ( long val ) : void
val long
return void
Ejemplo n.º 1
0
		/// <summary>
		/// Kills NPC, rewarding the killer.
		/// </summary>
		/// <param name="killer"></param>
		public override void Kill(Creature killer)
		{
			base.Kill(killer);

			this.DisappearTime = DateTime.Now.AddSeconds(20);

			if (killer == null)
				return;

			// Exp
			var exp = (long)(this.RaceData.Exp * ChannelServer.Instance.Conf.World.ExpRate);
			killer.GiveExp(exp);

			Send.CombatMessage(killer, "+{0} EXP", exp);
		}
Ejemplo n.º 2
0
		public override void Reward(Creature creature, Quest quest)
		{
			creature.GiveExp(this.Amount);
			Send.AcquireInfo(creature, "exp", this.Amount);
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Kills NPC, rewarding the killer.
        /// </summary>
        /// <param name="killer"></param>
        public override void Kill(Creature killer)
        {
            base.Kill(killer);

            this.DisappearTime = DateTime.Now.AddSeconds(NPC.DisappearDelay);

            if (killer == null)
                return;

            // Exp
            var exp = (long)(this.RaceData.Exp * ChannelServer.Instance.Conf.World.ExpRate);
            var expRule = killer.Party.ExpRule;

            if (!killer.IsInParty || expRule == PartyExpSharing.AllToFinish)
            {
                killer.GiveExp(exp);
                Send.CombatMessage(killer, "+{0} EXP", exp);
            }
            else
            {
                var members = killer.Party.GetMembers();
                var eaExp = 0L;
                var killerExp = 0L;
                var killerPos = killer.GetPosition();

                // Apply optional exp bonus
                if (members.Length > 1)
                {
                    var extra = members.Length - 1;
                    var bonus = ChannelServer.Instance.Conf.World.PartyExpBonus;

                    exp += (long)(exp * ((extra * bonus) / 100f));
                }

                // Official simply ALWAYS divides by party member total,
                // even if they cannot recieve the experience.
                if (expRule == PartyExpSharing.Equal)
                {
                    eaExp = exp / members.Length;
                    killerExp = eaExp;
                }
                else if (expRule == PartyExpSharing.MoreToFinish)
                {
                    exp /= 2;
                    eaExp = exp / members.Length;
                    killerExp = exp;
                }

                // Killer's exp
                killer.GiveExp(killerExp);
                Send.CombatMessage(killer, "+{0} EXP", killerExp);

                // Exp for members in range of killer, the range is unofficial
                foreach (var member in members.Where(a => a != killer && a.GetPosition().InRange(killerPos, 3000)))
                {
                    member.GiveExp(eaExp);
                    Send.CombatMessage(member, "+{0} EXP", eaExp);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles item burning, retruns whether it was successful.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="item"></param>
        /// <param name="campfire"></param>
        /// <param name="enchantersBurn"></param>
        public bool Burn(Creature creature, Item item, Prop campfire, bool enchantersBurn)
        {
            var skill = creature.Skills.Get(SkillId.Enchant);
            var enchantBurnSuccess = false;
            var powderBurnSuccess = false;
            var exp = 0;

            // Enchanter's Burn
            if (enchantersBurn)
            {
                var rnd = RandomProvider.Get();

                var isEquip = item.HasTag("/equip/");
                var hasEnchantBurnItems = (creature.Inventory.Has(51102) && creature.Inventory.Has(63016)); // Mana Herb + Holy Water

                // Enchant burning
                if (!isEquip || !hasEnchantBurnItems)
                {
                    // Unofficial
                    Send.SystemMessage(creature, Localization.Get("You don't the necessary items."));
                    return false;
                }

                // Get chances
                // All unofficial
                var rank = (skill == null ? 16 : (int)skill.Info.Rank);
                var enchantChance = (skill == null ? 0 : skill.RankData.Var3);

                // Campfire r8+ bonus
                if (enchantChance > 0 && campfire.Temp.CampfireSkillRank.Rank >= SkillRank.R8)
                    enchantChance += (16 - rank);

                // Powder = double enchant chance, based on the Wiki saying
                // r1 doesn't guarantee getting the enchants, but it does
                // guarantee getting powder.
                var powderChance = enchantChance * 2;

                // Debug
                if (creature.Titles.SelectedTitle == TitleId.devCAT)
                    Send.ServerMessage(creature, "Debug: Chance for enchant: {0:0}, chance for powder: {1:0}", enchantChance, powderChance);

                // Try prefix
                if (item.OptionInfo.Prefix != 0 && rnd.Next(100) < enchantChance)
                {
                    var enchant = Item.CreateEnchant(item.OptionInfo.Prefix);
                    creature.AcquireItem(enchant);
                    enchantBurnSuccess = true;
                }

                // Try suffix
                if (item.OptionInfo.Suffix != 0 && rnd.Next(100) < enchantChance)
                {
                    var enchant = Item.CreateEnchant(item.OptionInfo.Suffix);
                    creature.AcquireItem(enchant);
                    enchantBurnSuccess = true;
                }

                // Try suffix
                if (item.OptionInfo.Prefix + item.OptionInfo.Suffix != 0 && rnd.Next(100) < powderChance)
                {
                    var powder = new Item(62003); // Blessed Magic Powder
                    creature.AcquireItem(powder);
                    powderBurnSuccess = true;
                }

                // Reduce items
                creature.Inventory.Remove(51102, 1); // Mana Herb
                creature.Inventory.Remove(63016, 1); // Holy Water

                // Training
                this.BurnTraining(skill, enchantBurnSuccess, powderBurnSuccess);

                // Success/Fail motion
                Send.UseMotion(creature, 14, enchantBurnSuccess ? 0 : 3);
            }

            // Add exp based on item buying price (random+unofficial)
            if (item.OptionInfo.Price > 0)
            {
                exp = 40 + (int)(item.OptionInfo.Price / (float)item.Data.StackMax / 100f * item.Info.Amount);
                creature.GiveExp(exp);
            }

            // Remove item from cursor
            creature.Inventory.Remove(item);

            // Effect
            Send.Effect(MabiId.Broadcast, creature, Effect.BurnItem, campfire.EntityId, enchantBurnSuccess);
            Send.Notice(creature, NoticeType.MiddleSystem, Localization.Get("Burning EXP {0}"), exp);

            return true;
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Applies random fountain effect to creature.
		/// </summary>
		/// <param name="creature"></param>
		protected virtual void Touch(Creature creature)
		{
			var rnd = RandomProvider.Get();

			// All notices are unofficial

			switch (rnd.Next(15))
			{
				case 0: // Full Life
					{
						creature.FullLifeHeal();
						Send.Notice(creature, Localization.Get("Full Life"));
						break;
					}

				case 1: // 0 Injuries
					{
						creature.Injuries = 0;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Injuries"));
						break;
					}

				case 2: // Full Stamina
					{
						creature.Stamina = creature.StaminaMax;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("Full Stamina"));
						break;
					}

				case 3: // Full Mana
					{
						creature.Mana = creature.ManaMax;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("Full Mana"));
						break;
					}

				case 4: // No Hunger
					{
						creature.Hunger = 0;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Hunger"));
						break;
					}

				case 5: // Gold
					{
						creature.GiveItem(Item.CreateGold(rnd.Next(100, 200 + 1)));
						Send.Notice(creature, Localization.Get("Gold"));
						break;
					}

				case 6: // Exp
					{
						creature.GiveExp(1000);
						Send.Notice(creature, Localization.Get("Exp"));
						break;
					}

				case 7: // Bless All
					{
						var items = creature.Inventory.GetEquipment(a => a.IsBlessable);
						creature.Bless(items);
						Send.Notice(creature, Localization.Get("Blessed All"));
						break;
					}

				case 8: // Bless One
					{
						var equip = creature.Inventory.GetEquipment(a => !a.IsBlessed && a.IsBlessable);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.ElementAt(rnd.Next(count));
						creature.Bless(item);

						Send.Notice(creature, Localization.Get("Blessed {0}"), item.Data.Name);
						break;
					}

				case 9: // Repair One
					{
						var equip = creature.Inventory.GetEquipment(a => a.OptionInfo.Durability != a.OptionInfo.DurabilityMax);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.ElementAt(rnd.Next(count));
						item.OptionInfo.Durability = item.OptionInfo.DurabilityMax;
						Send.ItemDurabilityUpdate(creature, item);

						Send.Notice(creature, Localization.Get("Repaired {0}"), item.Data.Name);
						break;
					}

				case 10: // No Stamina and Hungry
					{
						creature.Stamina = 0;
						creature.Hunger = creature.StaminaMax;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Stamina and Hungry"));
						break;
					}

				case 11: // Lose one blessing
					{
						var equip = creature.Inventory.GetEquipment(a => a.IsBlessed);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.ElementAt(rnd.Next(count));
						item.OptionInfo.Flags &= ~ItemFlags.Blessed;
						Send.ItemBlessed(creature, item);

						Send.Notice(creature, Localization.Get("Lost blessing on {0}"), item.Data.Name);
						break;
					}

				case 12: // No Stamina
					{
						creature.Stamina = 0;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Stamina"));
						break;
					}

				case 13: // Random Injuries
					{
						creature.Injuries = rnd.Next((int)(creature.Life * 0.9f) + 1);
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("Random Injuries"));
						break;
					}

				case 14: // Lose one durability on random equip
					{
						var equip = creature.Inventory.GetEquipment(a => a.OptionInfo.Durability >= 1000);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.Random();
						creature.Inventory.ReduceDurability(item, 1000);

						Send.Notice(creature, Localization.Get("Repaired {0}"), item.Data.Name);
						break;
					}
			}
		}
Ejemplo n.º 6
0
		public override void Reward(Creature creature, Quest quest)
		{
			var amount = this.Amount;

			// Add global bonus
			float bonusMultiplier;
			string bonuses;
			if (ChannelServer.Instance.GameEventManager.GlobalBonuses.GetBonusMultiplier(GlobalBonusStat.QuestExp, out bonusMultiplier, out bonuses))
				amount = (int)(amount * bonusMultiplier);

			// Friday: Increase in rewards for completing part-time jobs.
			// (20% increase in EXP and Gold rewards)
			if (quest.Data.Type == QuestType.Deliver && ErinnTime.Now.Month == ErinnMonth.AlbanElved)
				amount = (int)(amount * 1.2f);

			creature.GiveExp(amount);
			Send.AcquireInfo(creature, "exp", amount);
		}
Ejemplo n.º 7
0
        public override void Reward(Creature creature, Quest quest)
        {
            var amount = this.Amount;

            // Friday: Increase in rewards for completing part-time jobs.
            // (20% increase in EXP and Gold rewards)
            if (quest.Data.Type == QuestType.Deliver && ErinnTime.Now.Month == ErinnMonth.AlbanElved)
                amount = (int)(amount * 1.2f);

            creature.GiveExp(amount);
            Send.AcquireInfo(creature, "exp", amount);
        }