Exemplo n.º 1
0
        /// <summary>
        /// Called when craft time is finished
        /// </summary>
        /// <param name="timer"></param>
        /// <returns></returns>
        protected static int ProceedSiegeWeapon(RegionTimer timer)
        {
            GamePlayer      player      = (GamePlayer)timer.Properties.getProperty <object>(AbstractCraftingSkill.PLAYER_CRAFTER, null);
            GameSiegeWeapon siegeWeapon = (GameSiegeWeapon)timer.Properties.getProperty <object>(AbstractCraftingSkill.RECIPE_BEING_CRAFTED, null);

            if (player == null || siegeWeapon == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("There was a problem getting back the item to the player in the secondary craft system.");
                }
                return(0);
            }
            if (!Util.Chance(CalculateSuccessChances(player, siegeWeapon)))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.ProceedSiegeWeapon.FailRepair", siegeWeapon.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                return(0);
            }
            siegeWeapon.Health = siegeWeapon.MaxHealth;
            player.CraftTimer.Stop();
            player.Out.SendCloseTimerWindow();
            player.Out.SendObjectUpdate(siegeWeapon);            //not sure if good packet for update
            player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.Proceed.FullyRepaired1", siegeWeapon.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
            return(0);
        }
Exemplo n.º 2
0
 public override void GainCraftingSkillPoints(GamePlayer player, Recipe recipe)
 {
     if (Util.Chance(CalculateChanceToGainPoint(player, recipe.Level)))
     {
         player.GainCraftingSkill(eCraftingSkill.SiegeCrafting, 1);
         player.Out.SendUpdateCraftingSkills();
     }
 }
Exemplo n.º 3
0
		/// <summary>
		/// Check whether or not to glare at this target.
		/// </summary>
		/// <param name="target">The potential target.</param>
		/// <returns>Whether or not the spell was cast.</returns>
		public bool CheckGlare(GameLiving target)
		{
			if (target == null || GlareTarget != null) return false;
			bool success = Util.Chance(GlareChance);
			if (success)
				GlareTarget = target;
			return success;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Check whether or not to cast a debuff on a ranged target.
		/// </summary>
		/// <param name="target">The potential target.</param>
		/// <returns>Whether or not the spell was cast.</returns>
		public bool CheckRangedDebuff(GamePlayer target)
		{
			if (target == null) return false;
			bool success = Util.Chance(RangedDebuffChance);
			if (success)
				CastRangedDebuff(target);
			return success;
		}
Exemplo n.º 5
0
 /// <summary>
 /// Gain a point in the appropriate skills for a recipe and materials
 /// </summary>
 public override void GainCraftingSkillPoints(GamePlayer player, DBCraftedItem recipe, IList <DBCraftedXItem> rawMaterials)
 {
     if (Util.Chance(CalculateChanceToGainPoint(player, recipe)))
     {
         player.GainCraftingSkill(eCraftingSkill.SiegeCrafting, 1);
         player.Out.SendUpdateCraftingSkills();
     }
 }
        /// <summary>
        /// Adds item to template reusing iventory  item instances from other templates.
        /// </summary>
        /// <param name="slot">The equipment slot</param>
        /// <param name="model">The equipment model</param>
        /// <param name="color">The equipment color</param>
        /// <param name="effect">The equipment effect</param>
        /// <param name="extension">The equipment extension</param>
        /// <returns>true if added</returns>
        public bool AddNPCEquipment(eInventorySlot slot, int model, int color, int effect, int extension, int emblem = 0)
        {
            lock (m_items)
            {
                lock (m_usedInventoryItems.SyncRoot)
                {
                    if (m_isClosed)
                    {
                        return(false);
                    }

                    slot = GetValidInventorySlot(slot);
                    if (slot == eInventorySlot.Invalid)
                    {
                        return(false);
                    }

                    // Changed to support randomization of slots - if we try to load a weapon in the same spot with a different model,
                    // let's make it random 50% chance to either overwrite the item or leave it be
                    if (m_items.ContainsKey(slot))
                    {
                        // 50% chance to keep the item we have
                        if (Util.Chance(50))
                        {
                            return(false);
                        }

                        // Let's remove the old item!
                        m_items.Remove(slot);
                    }

                    string        itemID = string.Format("{0}:{1},{2},{3}", slot, model, color, effect, extension);
                    InventoryItem item   = null;

                    if (!m_usedInventoryItems.ContainsKey(itemID))
                    {
                        item                = new GameInventoryItem();
                        item.Template       = new ItemTemplate();
                        item.Template.Id_nb = itemID;
                        item.Model          = model;
                        item.Color          = color;
                        item.Effect         = effect;
                        item.Extension      = (byte)extension;
                        item.Emblem         = emblem;
                        item.SlotPosition   = (int)slot;
                    }
                    else
                    {
                        return(false);
                    }

                    m_items.Add(slot, item);
                }
            }

            return(true);
        }
Exemplo n.º 7
0
		/// <summary>
		/// Try to get an AoE stun off.
		/// </summary>
		/// <param name="firstTime">
		/// Whether or not this is the first stun 
		/// (first stun will cast with 100% chance).
		/// </param>
		/// <returns>Whether or not the stun was cast.</returns>
		public bool CheckStun(bool firstTime)
		{
			if (GetSkillDisabledDuration(Stun) == 0 && (firstTime || Util.Chance(StunChance)))
			{
				PrepareToStun();
				return true;
			}
			return false;
		}
Exemplo n.º 8
0
 /// <summary>
 /// Gain a point in the appropriate skills for a recipe and materials
 /// </summary>
 public override void GainCraftingSkillPoints(GamePlayer player, DBCraftedItem recipe, IList <DBCraftedXItem> rawMaterials)
 {
     if (Util.Chance(CalculateChanceToGainPoint(player, recipe)))
     {
         if (player.GetCraftingSkillValue(eCraftingSkill.LeatherCrafting) < subSkillCap)
         {
             player.GainCraftingSkill(eCraftingSkill.LeatherCrafting, 1);
         }
         player.Out.SendUpdateCraftingSkills();
     }
 }
Exemplo n.º 9
0
 public override void GainCraftingSkillPoints(GamePlayer player, Recipe recipe)
 {
     if (Util.Chance(CalculateChanceToGainPoint(player, recipe.Level)))
     {
         if (player.GetCraftingSkillValue(eCraftingSkill.WoodWorking) < subSkillCap)
         {
             player.GainCraftingSkill(eCraftingSkill.WoodWorking, 1);
         }
         player.Out.SendUpdateCraftingSkills();
     }
 }
Exemplo n.º 10
0
		/// <summary>
		/// Check whether or not to throw this target into the air.
		/// </summary>
		/// <param name="target">The potential target.</param>
		/// <returns>Whether or not the target was thrown.</returns>
		public bool CheckThrow(GameLiving target)
		{
			if (target == null || !target.IsAlive || target.IsStunned)
				return false;

			bool success = Util.Chance(ThrowChance);

			if (success)
				ThrowLiving(target);

			return success;
		}
Exemplo n.º 11
0
        /// <summary>
        /// Called when craft time is finished
        /// </summary>
        /// <param name="timer"></param>
        /// <returns></returns>
        protected static int Proceed(RegionTimer timer)
        {
            GamePlayer    player       = (GamePlayer)timer.Properties.getProperty <object>(AbstractCraftingSkill.PLAYER_CRAFTER, null);
            GamePlayer    tradePartner = (GamePlayer)timer.Properties.getProperty <object>(PLAYER_PARTNER, null);
            InventoryItem item         = (InventoryItem)timer.Properties.getProperty <object>(AbstractCraftingSkill.RECIPE_BEING_CRAFTED, null);

            if (player == null || item == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("There was a problem getting back the item to the player in the secondary craft system.");
                }

                return(0);
            }

            player.CraftTimer.Stop();
            player.Out.SendCloseTimerWindow();

            if (Util.Chance(CalculateSuccessChances(player, item)))
            {
                int toRecoverCond = (int)((item.MaxCondition - item.Condition) * 0.01 / item.MaxCondition) + 1;
                if (toRecoverCond >= item.Durability)
                {
                    item.Condition += (int)(item.Durability * item.MaxCondition / 0.01);
                    item.Durability = 0;
                }
                else
                {
                    item.Condition   = item.MaxCondition;
                    item.Durability -= toRecoverCond;
                }

                player.Out.SendInventorySlotsUpdate(new int[] { item.SlotPosition });

                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.Proceed.FullyRepaired1", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                if (tradePartner != null)
                {
                    tradePartner.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.Proceed.FullyRepaired2", player.Name, item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
            }
            else
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.Proceed.FailImprove1", item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                if (tradePartner != null)
                {
                    tradePartner.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Repair.Proceed.FailImprove2", player.Name, item.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
            }

            return(0);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Pick a random style for now.
        /// </summary>
        /// <returns></returns>
        protected override Style GetStyleToUse()
        {
            if (Styles != null && Styles.Count > 0 && Util.Chance(Properties.GAMENPC_CHANCES_TO_STYLE + Styles.Count))
            {
                Style style = (Style)Styles[Util.Random(Styles.Count - 1)];
                if (StyleProcessor.CanUseStyle(this, style, AttackWeapon))
                {
                    return(style);
                }
            }

            return(base.GetStyleToUse());
        }
Exemplo n.º 13
0
        /// <summary>
        /// Make the item when craft time is finished
        /// </summary>
        protected virtual int MakeItem(RegionTimer timer)
        {
            GamePlayer             player       = timer.Properties.getProperty <GamePlayer>(PLAYER_CRAFTER, null);
            DBCraftedItem          recipe       = timer.Properties.getProperty <DBCraftedItem>(RECIPE_BEING_CRAFTED, null);
            IList <DBCraftedXItem> rawMaterials = timer.Properties.getProperty <IList <DBCraftedXItem> >(RECIPE_RAW_MATERIAL_LIST, null);

            if (player == null || recipe == null || rawMaterials == null)
            {
                if (player != null)
                {
                    player.Out.SendMessage("Could not find recipe or item to craft!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }

                log.Error("Crafting.MakeItem: Could not retrieve player, recipe, or raw materials to craft from CraftTimer.");
                return(0);
            }

            ItemTemplate itemToCraft = GameServer.Database.FindObjectByKey <ItemTemplate>(recipe.Id_nb);

            if (itemToCraft == null)
            {
                return(0);
            }

            player.CraftTimer.Stop();
            player.Out.SendCloseTimerWindow();

            if (Util.Chance(CalculateChanceToMakeItem(player, recipe)))
            {
                if (!RemoveUsedMaterials(player, recipe, rawMaterials))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.MakeItem.NotAllMaterials"), eChatType.CT_System, eChatLoc.CL_SystemWindow);

                    if (player.Client.Account.PrivLevel == 1)
                    {
                        return(0);
                    }
                }

                BuildCraftedItem(player, recipe, itemToCraft);
                GainCraftingSkillPoints(player, recipe, rawMaterials);
            }
            else
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.MakeItem.LoseNoMaterials", itemToCraft.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                player.Out.SendPlaySound(eSoundType.Craft, 0x02);
            }

            return(0);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Check whether or not to glare at this target.
        /// </summary>
        /// <param name="target">The potential target.</param>
        /// <returns>Whether or not the spell was cast.</returns>
        public bool CheckGlare(GameLiving target)
        {
            if (target == null || GlareTarget != null)
            {
                return(false);
            }
            bool success = Util.Chance(GlareChance);

            if (success)
            {
                GlareTarget = target;
            }
            return(success);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Check whether or not to cast a debuff on a ranged target.
        /// </summary>
        /// <param name="target">The potential target.</param>
        /// <returns>Whether or not the spell was cast.</returns>
        public bool CheckRangedDebuff(GamePlayer target)
        {
            if (target == null)
            {
                return(false);
            }
            bool success = Util.Chance(RangedDebuffChance);

            if (success)
            {
                CastRangedDebuff(target);
            }
            return(success);
        }
Exemplo n.º 16
0
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            if (Util.Chance(10))
            {
                ItemTemplate[] itemTemplates = null;

                eRealm realm = mob.CurrentZone.Realm;

                if (realm < eRealm._FirstPlayerRealm || realm > eRealm._LastPlayerRealm)
                {
                    realm = (eRealm)Util.Random((int)eRealm._FirstPlayerRealm, (int)eRealm._LastPlayerRealm);
                }

                switch (realm)
                {
                case eRealm.Albion:
                {
                    int index = Math.Min(m_itemTemplatesAlb.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesAlb[index];
                }
                break;

                case eRealm.Hibernia:
                {
                    int index = Math.Min(m_itemTemplatesHib.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesHib[index];
                    break;
                }

                case eRealm.Midgard:
                {
                    int index = Math.Min(m_itemTemplatesHib.Length - 1, mob.Level / LEVEL_RANGE);
                    itemTemplates = m_itemTemplatesMid[index];
                    break;
                }
                }

                if (itemTemplates != null && itemTemplates.Length > 0)
                {
                    ItemTemplate itemTemplate = itemTemplates[Util.Random(itemTemplates.Length - 1)];
                    loot.AddFixed(itemTemplate, 1);
                }
            }

            return(loot);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Check whether or not to throw this target into the air.
        /// </summary>
        /// <param name="target">The potential target.</param>
        /// <returns>Whether or not the target was thrown.</returns>
        public bool CheckThrow(GameLiving target)
        {
            if (target == null || !target.IsAlive || target.IsStunned)
            {
                return(false);
            }

            bool success = Util.Chance(ThrowChance);

            if (success)
            {
                ThrowLiving(target);
            }

            return(success);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Spawn some (10-20) nasty level 62-68 drakulvs around the spot the
        /// retriever has reported back from, then make these spawns aggro the
        /// raid inside the lair.
        /// </summary>
        /// <param name="numAdds"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void SpawnDrakulvs(int numAdds, float x, float y)
        {
            GameNPC drakulv;
            bool    isDisciple = false;

            for (int add = 0; add < numAdds; ++add)
            {
                isDisciple = Util.Chance(25);
                drakulv    = SpawnTimedAdd((isDisciple) ? 613 : 612, Util.Random(62, 68), x + Util.Random(250), y + Util.Random(250), 120, false);

                if (drakulv != null && drakulv.Brain is StandardMobBrain && this.Brain is DragonBrain)
                {
                    (Brain as DragonBrain).AddAggroListTo(drakulv.Brain as StandardMobBrain);
                }
            }
        }
Exemplo n.º 19
0
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot  = base.GenerateLoot(mob, killer);
            int      small = SMALLCHEST_CHANCE;
            int      large = LARGECHEST_CHANCE;

            if (Util.Chance(small))
            {
                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }

                int  minLoot    = ServerProperties.Properties.SMALLCHEST_MULTIPLIER * (lvl * lvl);
                long moneyCount = minLoot + Util.Random(minLoot >> 1);
                moneyCount = (long)((double)moneyCount * ServerProperties.Properties.MONEY_DROP);
                ItemTemplate money = new ItemTemplate();
                money.Model = 488;
                money.Name  = "small chest";
                money.Level = 0;
                money.Price = moneyCount;
                loot.AddFixed(money, 1);
            }

            if (Util.Chance(large))
            {
                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }

                int  minLoot    = ServerProperties.Properties.LARGECHEST_MULTIPLIER * (lvl * lvl);
                long moneyCount = minLoot + Util.Random(minLoot >> 1);
                moneyCount = (long)((double)moneyCount * ServerProperties.Properties.MONEY_DROP);
                ItemTemplate money = new ItemTemplate();
                money.Model = 488;
                money.Name  = "large chest";
                money.Level = 0;
                money.Price = moneyCount;
                loot.AddFixed(money, 1);
            }

            return(loot);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Spawn dogs that will despawn again after 60 seconds; there is
        /// a 25% chance that a retriever will spawn.
        /// </summary>
        /// <returns>Whether or not any retrievers were spawned.</returns>
        public override bool CheckAddSpawns()
        {
            base.CheckAddSpawns();              // In order to reset HealthPercentOld.

            Yell("Come to me my babies!");

            GameNPC dogSpawn;
            bool    isRetriever = false;

            m_retrieverList.Clear();

            // Spawn dogs, in most cases (75% chance) these dogs will be level
            // 37 and con green (decoys), in some cases (25%) they will be
            // retrievers, who will try to get out of the lair and, if successful,
            // cause Gjalpinulva to spawn a couple of deep purple adds.

            for (int dog = 1; dog <= 10; ++dog)
            {
                isRetriever = Util.Chance(25);
                dogSpawn    = SpawnTimedAdd(
                    (isRetriever) ? 610 : 611,
                    (isRetriever) ? Util.Random(47, 53) : 37,
                    Position.X + Util.Random(300, 600),
                    Position.Y + Util.Random(300, 600),
                    60,
                    isRetriever
                    );

                // We got a retriever, tell it who its master is and which exit
                // to run to.

                if (isRetriever)
                {
                    if (dogSpawn != null && dogSpawn.Brain != null && dogSpawn.Brain is RetrieverMobBrain)
                    {
                        (dogSpawn.Brain as RetrieverMobBrain).Master = this;
                        m_retrieverList.Add(dogSpawn);
                        dogSpawn.PathTo(GetExitCoordinates(Util.Random(1, 4)), 200);                            // Pick 1 out of 4 possible exits.
                    }
                }
            }
            return(true);
        }
Exemplo n.º 21
0
        protected virtual int MakeItem(RegionTimer timer)
        {
            GamePlayer player = timer.Properties.getProperty <GamePlayer>(PLAYER_CRAFTER);
            Recipe     recipe = timer.Properties.getProperty <Recipe>(RECIPE_BEING_CRAFTED);

            if (player == null || recipe == null)
            {
                if (player != null)
                {
                    player.Out.SendMessage("Could not find recipe or item to craft!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
                log.Error("Crafting.MakeItem: Could not retrieve player, recipe, or raw materials to craft from CraftTimer.");
                return(0);
            }

            player.CraftTimer.Stop();
            player.Out.SendCloseTimerWindow();

            if (Util.Chance(CalculateChanceToMakeItem(player, recipe.Level)))
            {
                if (!RemoveUsedMaterials(player, recipe))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.MakeItem.NotAllMaterials"), eChatType.CT_System, eChatLoc.CL_SystemWindow);

                    if (player.Client.Account.PrivLevel == 1)
                    {
                        return(0);
                    }
                }

                BuildCraftedItem(player, recipe);
                GainCraftingSkillPoints(player, recipe);
            }
            else
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.MakeItem.LoseNoMaterials", recipe.Product.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                player.Out.SendPlaySound(eSoundType.Craft, 0x02);
            }
            return(0);
        }
Exemplo n.º 22
0
        /// <summary>
        /// This is the GameTimer callback that will be called to test if to start
        /// a weather or not
        /// </summary>
        /// <param name="state"></param>
        private void CheckWeatherTimerCallback(object state)
        {
            if (IsActive)
            {
                return;
            }

            //Reset the weather start tick so it can not overflow
            m_weatherStartTick = 0;

            //Test our chance to start the weather
            if (!Util.Chance(ServerProperties.Properties.WEATHER_CHANCE))
            {
                return;
            }

            //Start the weather
            StartStorm();

            m_weatherTimer.Change(ServerProperties.Properties.WEATHER_CHECK_INTERVAL + ZONE_WIDTH * 1000 / m_speed, ServerProperties.Properties.WEATHER_CHECK_INTERVAL);
            return;             //0xFFFFF/speed*10 to wait time of storm  before check
        }
Exemplo n.º 23
0
        /// <summary>
        /// Weather Tick happen when Default Timer is Off or When Weather is Finished.
        /// </summary>
        /// <param name="regionId">Region Id of the Weather</param>
        /// <returns>Delay Time for next Tick</returns>
        private int OnWeatherTick(ushort regionId)
        {
            try
            {
                var weather = this[regionId];

                if (weather == null)
                {
                    return(0);
                }

                if (!Util.Chance(DefaultWeatherChance))
                {
                    if (weather.StartTime != 0)
                    {
                        StopWeather(weather);
                    }

                    return(DefaultTimerInterval);
                }

                weather.CreateWeather(SimpleScheduler.Ticks);
                StartWeather(weather);

                return(weather.Duration);
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Exception in Weather Manager On Tick: ", ex);
                }

                return(DefaultTimerInterval);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Spawn dogs that will despawn again after 60 seconds; there is
        /// a 25% chance that a retriever will spawn.
        /// </summary>
        /// <returns>Whether or not any retrievers were spawned.</returns>
        public override bool CheckAddSpawns()
        {
            base.CheckAddSpawns();  // In order to reset HealthPercentOld.

            GameNPC glimmerSpawn;
            bool    isMessenger;

            m_messengerList.Clear();

            // Spawn glimmer mobs, in most cases (75% chance) these mobs will be around
            // level 60 and con red to purple, in some cases (25%) they will be
            // messengers, who will try to get out of the lair and, if successful,
            // cause Cuuldurach to spawn a couple of deep purple adds.
            for (int glimmer = 1; glimmer <= 10; ++glimmer)
            {
                isMessenger  = Util.Chance(25);
                glimmerSpawn = SpawnTimedAdd(
                    isMessenger ? 620 : 621 + Util.Random(2),
                    isMessenger ? Util.Random(47, 53) : Util.Random(57, 63),
                    X + Util.Random(300, 600), Y + Util.Random(300, 600), 60, isMessenger);

                // We got a messenger, tell it who its master is and which exit
                // to run to.
                if (isMessenger)
                {
                    if (glimmerSpawn != null && glimmerSpawn.Brain != null && glimmerSpawn.Brain is RetrieverMobBrain)
                    {
                        (glimmerSpawn.Brain as RetrieverMobBrain).Master = this;
                        m_messengerList.Add(glimmerSpawn);
                        glimmerSpawn.WalkTo(GetExitCoordinates(Util.Random(1, 4)), 200);    // Pick 1 out of 4 possible exits.
                    }
                }
            }

            return(true);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Apply all spellcraft gems bonus
        /// </summary>
        /// <param name="player"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        private void ApplySpellcraftGems(GamePlayer player, InventoryItem item)
        {
            int maxBonusLevel = GetItemMaxImbuePoints(item);
            int bonusLevel    = GetTotalImbuePoints(player, item);

            int sucessChances = 100;

            if (bonusLevel > maxBonusLevel)
            {
                sucessChances = CalculateChanceToOverchargeItem(player, item, maxBonusLevel, bonusLevel);
            }
            int destroyChance = 100 - CalculateChanceToPreserveItem(player, item, maxBonusLevel, bonusLevel);


            GamePlayer tradePartner = player.TradeWindow.Partner;

            if (Util.Chance(sucessChances))
            {
                lock (player.TradeWindow.Sync)
                {
                    player.Inventory.BeginChanges();
                    foreach (InventoryItem gem in (ArrayList)player.TradeWindow.TradeItems.Clone())
                    {
                        if (item.Bonus1Type == 0)
                        {
                            item.Bonus1Type = gem.Bonus1Type;
                            item.Bonus1     = gem.Bonus1;
                        }
                        else if (item.Bonus2Type == 0)
                        {
                            item.Bonus2Type = gem.Bonus1Type;
                            item.Bonus2     = gem.Bonus1;
                        }
                        else if (item.Bonus3Type == 0)
                        {
                            item.Bonus3Type = gem.Bonus1Type;
                            item.Bonus3     = gem.Bonus1;
                        }
                        else if (item.Bonus4Type == 0)
                        {
                            item.Bonus4Type = gem.Bonus1Type;
                            item.Bonus4     = gem.Bonus1;
                        }
                        player.Inventory.RemoveCountFromStack(gem, 1);
                        InventoryLogging.LogInventoryAction(player, "(craft)", eInventoryActionType.Craft, gem.Template);
                    }
                    player.Inventory.CommitChanges();
                }

                if (tradePartner != null)
                {
                    tradePartner.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "SpellCrafting.ApplySpellcraftGems.ImbuedItem", player.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "SpellCrafting.ApplySpellcraftGems.ImbuedItem", player.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
            }
            else if (Util.Chance(destroyChance))
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "SpellCrafting.ApplySpellcraftGems.PowerExplodes"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);

                lock (player.TradeWindow.Sync)
                {
                    player.Inventory.BeginChanges();
                    // Luhz Crafting Update:
                    // The base item is no longer lost when spellcrafting explodes - only gems are destroyed.
                    foreach (InventoryItem gem in (ArrayList)player.TradeWindow.TradeItems.Clone())
                    {
                        if (gem.Object_Type == (int)eObjectType.SpellcraftGem)
                        {
                            player.Inventory.RemoveCountFromStack(gem, 1);
                            InventoryLogging.LogInventoryAction(player, "(craft)", eInventoryActionType.Craft, gem.Template);
                        }
                    }
                    player.Inventory.CommitChanges();
                }

                player.Emote(eEmote.SpellGoBoom);
                player.Health = 0;
                player.Die(player);                 // On official you take damages
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "SpellCrafting.ApplySpellcraftGems.Failed"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);

                if (tradePartner != null)
                {
                    if (Util.Chance(40))
                    {
                        tradePartner.Emote(eEmote.SpellGoBoom);
                        tradePartner.Health = 0;
                        tradePartner.Die(player);
                    }
                    tradePartner.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "SpellCrafting.ApplySpellcraftGems.Failed"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
            }
            else
            {
                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "SpellCrafting.ApplySpellcraftGems.Failed"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                if (tradePartner != null)
                {
                    tradePartner.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "SpellCrafting.ApplySpellcraftGems.Failed"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Disguise the doppelganger as an invader
        /// </summary>
        protected void Disguise()
        {
            if (Util.Chance(50))
            {
                Gender = eGender.Male;
            }
            else
            {
                Gender = eGender.Female;
            }

            ICharacterClass characterClass = new DefaultCharacterClass();

            switch (Util.Random(2))
            {
            case 0:     // Albion
                Name = $"Albion {LanguageMgr.GetTranslation(LanguageMgr.DefaultLanguage, "GamePlayer.RealmTitle.Invader")}";

                switch (Util.Random(4))
                {
                case 0:         // Archer
                    Inventory = ClothingMgr.Albion_Archer.CloneTemplate();
                    SwitchWeapon(eActiveWeaponSlot.Distance);
                    characterClass = new ClassScout();
                    break;

                case 1:         // Caster
                    Inventory      = ClothingMgr.Albion_Caster.CloneTemplate();
                    characterClass = new ClassTheurgist();
                    break;

                case 2:         // Fighter
                    Inventory      = ClothingMgr.Albion_Fighter.CloneTemplate();
                    characterClass = new ClassArmsman();
                    break;

                case 3:         // GuardHealer
                    Inventory      = ClothingMgr.Albion_Healer.CloneTemplate();
                    characterClass = new ClassCleric();
                    break;

                case 4:         // Stealther
                    Inventory      = ClothingMgr.Albion_Stealther.CloneTemplate();
                    characterClass = new ClassInfiltrator();
                    break;
                }
                break;

            case 1:     // Hibernia
                Name = $"Hibernia {LanguageMgr.GetTranslation(LanguageMgr.DefaultLanguage, "GamePlayer.RealmTitle.Invader")}";

                switch (Util.Random(4))
                {
                case 0:         // Archer
                    Inventory = ClothingMgr.Hibernia_Archer.CloneTemplate();
                    SwitchWeapon(eActiveWeaponSlot.Distance);
                    characterClass = new ClassRanger();
                    break;

                case 1:         // Caster
                    Inventory      = ClothingMgr.Hibernia_Caster.CloneTemplate();
                    characterClass = new ClassEldritch();
                    break;

                case 2:         // Fighter
                    Inventory      = ClothingMgr.Hibernia_Fighter.CloneTemplate();
                    characterClass = new ClassArmsman();
                    break;

                case 3:         // GuardHealer
                    Inventory      = ClothingMgr.Hibernia_Healer.CloneTemplate();
                    characterClass = new ClassDruid();
                    break;

                case 4:         // Stealther
                    Inventory      = ClothingMgr.Hibernia_Stealther.CloneTemplate();
                    characterClass = new ClassNightshade();
                    break;
                }
                break;

            case 2:     // Midgard
                Name = $"Midgard {LanguageMgr.GetTranslation(LanguageMgr.DefaultLanguage, "GamePlayer.RealmTitle.Invader")}";

                switch (Util.Random(4))
                {
                case 0:         // Archer
                    Inventory = ClothingMgr.Midgard_Archer.CloneTemplate();
                    SwitchWeapon(eActiveWeaponSlot.Distance);
                    characterClass = new ClassHunter();
                    break;

                case 1:         // Caster
                    Inventory      = ClothingMgr.Midgard_Caster.CloneTemplate();
                    characterClass = new ClassRunemaster();
                    break;

                case 2:         // Fighter
                    Inventory      = ClothingMgr.Midgard_Fighter.CloneTemplate();
                    characterClass = new ClassWarrior();
                    break;

                case 3:         // GuardHealer
                    Inventory      = ClothingMgr.Midgard_Healer.CloneTemplate();
                    characterClass = new ClassHealer();
                    break;

                case 4:         // Stealther
                    Inventory      = ClothingMgr.Midgard_Stealther.CloneTemplate();
                    characterClass = new ClassShadowblade();
                    break;
                }
                break;
            }

            var possibleRaces = characterClass.EligibleRaces;
            var indexPick     = Util.Random(0, possibleRaces.Count - 1);

            Model = (ushort)possibleRaces[indexPick].GetModel(Gender);

            bool distance  = Inventory.GetItem(eInventorySlot.DistanceWeapon) != null;
            bool standard  = Inventory.GetItem(eInventorySlot.RightHandWeapon) != null;
            bool twoHanded = Inventory.GetItem(eInventorySlot.TwoHandWeapon) != null;

            if (distance)
            {
                SwitchWeapon(eActiveWeaponSlot.Distance);
            }
            else if (standard && twoHanded)
            {
                if (Util.Random(1) < 1)
                {
                    SwitchWeapon(eActiveWeaponSlot.Standard);
                }
                else
                {
                    SwitchWeapon(eActiveWeaponSlot.TwoHanded);
                }
            }
            else if (twoHanded)
            {
                SwitchWeapon(eActiveWeaponSlot.TwoHanded);
            }
            else
            {
                SwitchWeapon(eActiveWeaponSlot.Standard);
            }
        }
Exemplo n.º 27
0
        public virtual void SetInventoryTemplate()
        {
            var template = new GameNpcInventoryTemplate();

            switch (Realm)
            {
            case eRealm.Albion:
            {
                Model = 92;
                template.AddNPCEquipment(eInventorySlot.RightHandWeapon, 310, 81);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 1301);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 1312);

                if (Util.Chance(50))
                {
                    template.AddNPCEquipment(eInventorySlot.TorsoArmor, 1005, 67);
                }
                else
                {
                    template.AddNPCEquipment(eInventorySlot.TorsoArmor, 1313);
                }

                template.AddNPCEquipment(eInventorySlot.Cloak, 669, 65);
            }
            break;

            case eRealm.Midgard:
            {
                Model = 156;
                template.AddNPCEquipment(eInventorySlot.RightHandWeapon, 321, 81);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 1301);
                template.AddNPCEquipment(eInventorySlot.LegsArmor, 1303);

                if (Util.Chance(50))
                {
                    template.AddNPCEquipment(eInventorySlot.TorsoArmor, 1300);
                }
                else
                {
                    template.AddNPCEquipment(eInventorySlot.TorsoArmor, 993);
                }

                template.AddNPCEquipment(eInventorySlot.Cloak, 669, 51);
            }
            break;

            case eRealm.Hibernia:
            {
                Model = 335;
                template.AddNPCEquipment(eInventorySlot.RightHandWeapon, 457, 81);
                template.AddNPCEquipment(eInventorySlot.FeetArmor, 1333);

                if (Util.Chance(50))
                {
                    template.AddNPCEquipment(eInventorySlot.TorsoArmor, 1336);
                }
                else
                {
                    template.AddNPCEquipment(eInventorySlot.TorsoArmor, 1008);
                }

                template.AddNPCEquipment(eInventorySlot.Cloak, 669);
            }
            break;
            }

            Inventory = template.CloseTemplate();
        }
Exemplo n.º 28
0
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList lootList = new LootList();

            // check to see if we are in ToA
            if (mob.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis && killer.CurrentRegion.Expansion == (int)eClientExpansion.TrialsOfAtlantis)
            {
                if (mob.Level >= 45 && Util.Chance(ServerProperties.Properties.SCROLL_DROP_RATE))
                {
                    List <Artifact> artifacts = new List <Artifact>();

                    if (mob.CurrentRegion.IsDungeon && Util.Chance((int)(ServerProperties.Properties.SCROLL_DROP_RATE * 1.5)))
                    {
                        artifacts = ArtifactMgr.GetArtifacts();
                    }
                    else
                    {
                        switch (mob.CurrentZone.Description)
                        {
                        case "Oceanus Hesperos":
                        case "Mesothalassa":
                        case "Oceanus Notos":
                        case "Oceanus Boreal":
                        case "Oceanus Anatole":
                            artifacts = ArtifactMgr.GetArtifacts("Oceanus");
                            break;

                        case "Stygian Delta":
                        case "Land of Atum":
                            artifacts = ArtifactMgr.GetArtifacts("Stygia");
                            break;

                        case "Arbor Glen":
                        case "Green Glades":
                            artifacts = ArtifactMgr.GetArtifacts("Aerus");
                            break;

                        case "Typhon's Reach":
                        case "Ashen Isles":
                            artifacts = ArtifactMgr.GetArtifacts("Volcanus");
                            break;
                        }
                    }

                    if (artifacts.Count > 0)
                    {
                        string artifactID = artifacts[Util.Random(artifacts.Count - 1)].ArtifactID;
                        int    pageNumber;

                        ItemTemplate loot = new ItemTemplate();
                        loot.AllowAdd = false;

                        if (mob.Level > 55)
                        {
                            pageNumber = 3;
                        }
                        else if (mob.Level >= 51)
                        {
                            pageNumber = 2;
                        }
                        else
                        {
                            pageNumber = 1;
                        }

                        loot.Model = 488;
                        loot.Name  = "scroll|" + artifactID + "|" + pageNumber;
                        loot.Level = 35;

                        lootList.AddFixed(loot, 1);
                    }
                }
            }

            return(lootList);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns></returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }


                ItemTemplate atlanteanGlass = new ItemTemplate(m_atlanteanglass);

                int killedcon = (int)player.GetConLevel(mob) + 3;

                if (killedcon <= 0)
                {
                    return(loot);
                }

                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }
                int maxcount = 1;

                //Switch pack size
                if (lvl > 0 && lvl < 10)
                {
                    //Single AtlanteanGlass
                    maxcount = (int)Math.Floor((double)(lvl / 2)) + 1;
                }
                else if (lvl >= 10 && lvl < 20)
                {
                    //Double
                    atlanteanGlass.PackSize = 2;
                    maxcount = (int)Math.Floor((double)((lvl - 10) / 2)) + 1;
                }
                else if (lvl >= 20 && lvl < 30)
                {
                    //Triple
                    atlanteanGlass.PackSize = 3;
                    maxcount = (int)Math.Floor((double)((lvl - 20) / 2)) + 1;
                }
                else if (lvl >= 30 && lvl < 40)
                {
                    //Quad
                    atlanteanGlass.PackSize = 4;
                    maxcount = (int)Math.Floor((double)((lvl - 30) / 2)) + 1;
                }
                else if (lvl >= 40 && lvl < 50)
                {
                    //Quint
                    atlanteanGlass.PackSize = 5;
                    maxcount = (int)Math.Floor((double)((lvl - 40) / 2)) + 1;
                }
                else
                {
                    //Cache (x10)
                    atlanteanGlass.PackSize = 10;
                    maxcount = (int)Math.Round((double)(lvl / 10));
                }

                if (!mob.Name.ToLower().Equals(mob.Name))
                {
                    //Named mob, more cash !
                    maxcount = (int)Math.Round(maxcount * ServerProperties.Properties.LOOTGENERATOR_ATLANTEANGLASS_NAMED_COUNT);
                }

                if (maxcount > 0 && Util.Chance(ServerProperties.Properties.LOOTGENERATOR_ATLANTEANGLASS_BASE_CHANCE + Math.Max(10, killedcon)))
                {
                    loot.AddFixed(atlanteanGlass, maxcount);
                }
            }
            catch
            {
                return(loot);
            }

            return(loot);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Generate loot for given mob
        /// </summary>
        /// <param name="mob"></param>
        /// <param name="killer"></param>
        /// <returns>Lootlist with Aurulite drops</returns>
        public override LootList GenerateLoot(GameNPC mob, GameObject killer)
        {
            LootList loot = base.GenerateLoot(mob, killer);

            // ItemTemplate aurulite = new ItemTemplate(m_aurulite);  Creating a new ItemTemplate throws an exception later
            ItemTemplate aurulite = GameServer.Database.FindObjectByKey <ItemTemplate>(m_aurulite.Id_nb);


            try
            {
                GamePlayer player = killer as GamePlayer;
                if (killer is GameNPC && ((GameNPC)killer).Brain is IControlledBrain)
                {
                    player = ((ControlledNpcBrain)((GameNPC)killer).Brain).GetPlayerOwner();
                }
                if (player == null)
                {
                    return(loot);
                }

                int killedcon = (int)player.GetConLevel(mob) + 3;

                if (killedcon <= 0)
                {
                    return(loot);
                }

                int lvl = mob.Level + 1;
                if (lvl < 1)
                {
                    lvl = 1;
                }
                int maxcount = 1;

                //Switch pack size
                if (lvl > 0 && lvl < 10)
                {
                    //Aurulite only
                    maxcount = (int)Math.Floor((double)(lvl / 2)) + 1;
                }
                else if (lvl >= 10 && lvl < 20)
                {
                    //Aurulire Chip (x5)
                    aurulite.PackSize = 5;
                    maxcount          = (int)Math.Floor((double)((lvl - 10) / 2)) + 1;
                }
                else if (lvl >= 20 && lvl < 30)
                {
                    //Aurulite Fragment (x10)
                    aurulite.PackSize = 10;
                    maxcount          = (int)Math.Floor((double)((lvl - 20) / 2)) + 1;
                }
                else if (lvl >= 30 && lvl < 40)
                {
                    //Aurulite Shard (x20)
                    aurulite.PackSize = 20;
                    maxcount          = (int)Math.Floor((double)((lvl - 30) / 2)) + 1;
                }
                else if (lvl >= 40 && lvl < 50)
                {
                    //Aurulite Cluster (x30)
                    aurulite.PackSize = 30;
                    maxcount          = (int)Math.Floor((double)((lvl - 40) / 2)) + 1;
                }
                else
                {
                    //Aurulite Cache (x40)
                    aurulite.PackSize = 40;
                    maxcount          = (int)Math.Round((double)(lvl / 10));
                }

                if (!mob.Name.ToLower().Equals(mob.Name))
                {
                    //Named mob, more cash !
                    maxcount = (int)Math.Round(maxcount * ServerProperties.Properties.LOOTGENERATOR_AURULITE_NAMED_COUNT);
                }

                // add to loot
                if (maxcount > 0 && Util.Chance(ServerProperties.Properties.LOOTGENERATOR_AURULITE_BASE_CHANCE + Math.Max(10, killedcon)))
                {
                    // Add to fixed to prevent overrides with loottemplate
                    loot.AddFixed(aurulite, (int)Math.Ceiling(maxcount * ServerProperties.Properties.LOOTGENERATOR_AURULITE_AMOUNT_RATIO));
                }
            }
            catch
            {
                // Prevent displaying errors
                return(loot);
            }

            return(loot);
        }