Exemplo n.º 1
0
        public override void DoDamage()
        {
            // InventoryItem ammo = this.Ammo[AmmoSlot] as InventoryItem;
            // todo remove ammo + spell in db and uncomment
            // m_spellHandler.StartSpell(player);
            base.DoDamage();// anim mut be called after damage
            if (GroundTarget == null)
            {
                return;
            }

            IList targets = SelectTargets();

            foreach (GameLiving living in targets)
            {
                int damageAmount = 50 + Util.Random(200);
                living.TakeDamage(Owner, eDamageType.Crush, damageAmount, 0);
                Owner.Out.SendMessage("The " + Name + " hits " + living.Name + " for " + damageAmount + " damage!", eChatType.CT_YouHit,
                                      eChatLoc.CL_SystemWindow);
                foreach (GamePlayer player in living.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                {
                    player.Out.SendCombatAnimation(this, living, 0x0000, 0x0000, 0x00, 0x00, 0x14, living.HealthPercent);
                }
            }

            return;
        }
        /// <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);

            int lvl = mob.Level + 1;

            if (lvl < 1)
            {
                lvl = 1;
            }
            int minLoot = 2 + ((lvl * lvl * lvl) >> 3);

            long moneyCount = minLoot + Util.Random(minLoot >> 1);

            moneyCount = (long)((double)moneyCount * ServerProperties.Properties.MONEY_DROP);

            ItemTemplate money = new ItemTemplate();

            money.Model = 488;
            money.Name  = "bag of coins";
            money.Level = 0;

            money.Price = moneyCount;

            loot.AddFixed(money, 1);
            return(loot);
        }
        public static int SpawnChests(RegionTimer timer)
        {
            Console.WriteLine("Treasure Chests created");
            IList <ItemTemplate> items = GameServer.Database.SelectObjects <ItemTemplate>("PackageID = '" + GameServer.Database.Escape("DragonWeapons") + "' OR PackageID = '" + GameServer.Database.Escape("LabWeaps") + "' OR PackageID = '" + GameServer.Database.Escape("Artifacts") + "'");

            for (int i = 0; i < numberOfChests; i++)
            {
                TreasureChest chest = new TreasureChest(items);
                //15k
                chest.X               = Util.Random(startX - radius, startX + radius);
                chest.Y               = Util.Random(startY - radius, startY + radius);
                chest.Z               = 10000;
                chest.Heading         = 13;
                chest.CurrentRegionID = currentregionID;
                chest.Model           = 1596;
                chest.AddToWorld();
            }
            foreach (GameClient client in WorldMgr.GetAllPlayingClients())
            {
                client.Player.TempProperties.removeProperty("Treasure_Chest");
                client.Out.SendMessage(numberOfChests + " Treasure Chests created in this zone", eChatType.CT_ScreenCenter, eChatLoc.CL_SystemWindow);
                client.Out.SendMessage(numberOfChests + " Treasure Chests created in this zone", eChatType.CT_ScreenCenter, eChatLoc.CL_SystemWindow);
                client.Out.SendMessage(numberOfChests + " Treasure Chests created in this zone", eChatType.CT_ScreenCenter, eChatLoc.CL_SystemWindow);
            }
            Mob mob = GameServer.Database.SelectObject <Mob>("Name = '" + GameServer.Database.Escape("Redemption") + "'");

            if (mob != null)
            {
                GameNPC npc = new GameNPC();
                npc.LoadFromDatabase(mob);
                new RegionTimer(npc, new RegionTimerCallback(SpawnChests), (TreasureChestRecastDelay * 60 * 1000));
            }
            return(0);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Starts a melee or ranged attack on a given target.
        /// </summary>
        /// <param name="attackTarget">The object to attack.</param>
        public override void StartAttack(GameObject attackTarget)
        {
            // Don't allow ranged attacks
            if (ActiveWeaponSlot == eActiveWeaponSlot.Distance)
            {
                bool standard  = Inventory.GetItem(eInventorySlot.RightHandWeapon) != null;
                bool twoHanded = Inventory.GetItem(eInventorySlot.TwoHandWeapon) != null;

                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);
                }
            }
            base.StartAttack(attackTarget);
        }
Exemplo n.º 5
0
        /// <summary>
        /// when the relic is lost and ReturnRelicInterval is elapsed
        /// </summary>
        protected virtual int ReturnRelicTick(RegionTimer timer)
        {
            if (CurrentRegion.Time - m_timeRelicOnGround < ReturnRelicInterval)
            {
                // Note: This does not show up, possible issue with SendSpellEffect
                ushort effectID = (ushort)Util.Random(5811, 5815);
                foreach (GamePlayer ppl in GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                {
                    ppl.Out.SendSpellEffectAnimation(this, this, effectID, 0, false, 0x01);
                }

                return(RelicEffectInterval);
            }

            if (ReturnRelicPad != null)
            {
                log.Debug("Relic " + Name + " is lost and returns to " + ReturnRelicPad.ToString());
                RemoveFromWorld();
                RelicPadTakesOver(ReturnRelicPad, true);
                SaveIntoDatabase();
                AddToWorld();
            }
            else
            {
                log.Error("Relic " + Name + " is lost and ReturnRelicPad is null!");
            }

            m_returnRelicTimer.Stop();
            m_returnRelicTimer = null;
            return(0);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets mob template by ID, returns random if multiple templates with same ID
        /// </summary>
        /// <param name="templateId">The mob template ID</param>
        /// <returns>The mob template or null if nothing is found</returns>
        public static NpcTemplate GetTemplate(int templateId)
        {
            if (templateId == -1)
            {
                return(null);
            }

            lock (m_mobTemplates.SyncRoot)
            {
                object entry = m_mobTemplates[templateId];
                if (entry is ArrayList)
                {
                    ArrayList array = (ArrayList)entry;
                    return((NpcTemplate)array[Util.Random(array.Count - 1)]);
                }
                else if (entry == null)
                {
                    // if (log.IsWarnEnabled)
                    // log.Warn("No npctemplate with ID " + templateId + " found.");
                    return(null);
                }

                return((NpcTemplate)entry);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// The callback for the pulsing spelleffect
        /// </summary>
        /// <param name="timer">The ObjectTimerCallback object</param>
        private int CarrierTimerTick(RegionTimer timer)
        {
            // update the relic position
            Update();

            // check to make sure relic is in a legal region and still in the players backpack
            if (GameServer.KeepManager.FrontierRegionsList.Contains(CurrentRegionID) == false)
            {
                log.DebugFormat("{0} taken out of frontiers, relic returned to previous pad.", Name);
                RelicPadTakesOver(ReturnRelicPad, true);
                SaveIntoDatabase();
                AddToWorld();
                return(0);
            }

            if (CurrentCarrier != null && CurrentCarrier.Inventory.GetFirstItemByID(m_item.Id_nb, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack) == null)
            {
                log.DebugFormat("{0} not found in carriers backpack, relic returned to previous pad.", Name);
                RelicPadTakesOver(ReturnRelicPad, true);
                SaveIntoDatabase();
                AddToWorld();
                return(0);
            }

            // fireworks spells temp
            ushort effectID = (ushort)Util.Random(5811, 5815);

            foreach (GamePlayer ppl in m_currentCarrier.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
            {
                ppl.Out.SendSpellEffectAnimation(m_currentCarrier, m_currentCarrier, effectID, 0, false, 0x01);
            }

            return(RelicEffectInterval);
        }
Exemplo n.º 8
0
 /// <summary>
 /// This method forces the weather for this region to start with a random intensity,
 /// no matter if it is already active or not
 /// </summary>
 public void StartStorm()
 {
     StartStorm(1,
                (uint)Util.Random(25000, 90000),
                (ushort)Util.Random(100, 700),
                (ushort)Util.Random(16000, 32000),
                (ushort)Util.Random(30, 100));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Create Random Weather for this Region
 /// </summary>
 /// <param name="StartTime">StartTime of the Weather</param>
 public void CreateWeather(long StartTime)
 {
     CreateWeather(
         (uint)Util.Random(25000, 90000),
         (ushort)Util.Random(100, 700),
         (ushort)Util.Random(30, 110),
         (ushort)Util.Random(16000, 32000),
         StartTime);
 }
Exemplo n.º 10
0
		/// <summary>
		/// Announce the Breath attack and start the 5 second timer.
		/// </summary>
		private void PrepareToBreathe()
		{
			// Prevent brain from casting this over and over.

			HealthPercentOld = HealthPercent;	
			int messageNo = Util.Random(1, m_breathAnnounce.Length) - 1;
			BroadcastMessage(String.Format(m_breathAnnounce[messageNo], Name));
			new RegionTimer(this, new RegionTimerCallback(CastBreath), 5000);
		}
Exemplo n.º 11
0
        /// <summary>
        /// Summon the pet
        /// </summary>
        protected virtual void SummonPet()
        {
            if (PetTemplate != null && PetLevel != 0 && m_pet == null)
            {
                m_pet = new GameNPC(PetTemplate);
                if (m_pet != null)
                {
                    m_pet.CurrentRegion = CurrentRegion;

                    // Summon pet to the left or right of the summoner
                    ushort sideHeading = (ushort)(Heading + 900);
                    if (Util.Random(1) < 1)
                    {
                        sideHeading += 1800;
                    }
                    Point2D point = GetPointFromHeading(sideHeading, PetSummonDistance);
                    m_pet.X = point.X;
                    m_pet.Y = point.Y;
                    m_pet.Z = Z;

                    m_pet.Heading          = Heading;
                    m_pet.Realm            = eRealm.None;
                    m_pet.LoadedFromScript = true;
                    m_pet.MaxDistance      = PetMaxDistance;
                    m_pet.TetherRange      = PetTetherRange;
                    m_pet.RespawnInterval  = -1;
                    m_pet.IsWorthReward    = false;

                    if (PetSize > 0)
                    {
                        m_pet.Size = PetSize;
                    }

                    if (PetLevel > 0)
                    {
                        m_pet.Level = PetLevel;
                    }
                    else
                    {
                        m_pet.Level = (byte)(Level * PetLevel / -100);
                    }

                    m_pet.AutoSetStats();

                    if (m_pet.Brain is StandardMobBrain petBrain && Brain is StandardMobBrain brain && TargetObject is GameLiving living)
                    {
                        petBrain.CanBAF = false;
                        brain.AddAggroListTo(petBrain);
                    }

                    m_pet.AddToWorld();

                    m_resummonTime = CurrentRegion.Time + PetResummonTime;
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Spawn adds that will despawn again after 30 seconds.
        /// For Golestandt, these will be level 57-60 GameNPCs and
        /// their numbers will depend on the number of players inside
        /// the lair.
        /// </summary>
        /// <returns>Whether or not any adds were spawned.</returns>
        public override bool CheckAddSpawns()
        {
            base.CheckAddSpawns();              // In order to reset HealthPercentOld.

            int numAdds = Math.Max(1, PlayersInLair / 2);

            for (int add = 1; add <= numAdds; ++add)
            {
                SpawnTimedAdd(600, Util.Random(57, 60), X + Util.Random(300, 600), Y + Util.Random(300, 600), 30, false);                       // granite giant pounder lvl 57-60
            }
            return(true);
        }
Exemplo n.º 13
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.º 14
0
        public override bool WhisperReceive(GameLiving source, string text)
        {
            GamePlayer player = source as GamePlayer;

            if (player == null)
            {
                return(false);
            }

            if (player.InCombat)
            {
                return(false);
            }

            if (player.Client.Account.PrivLevel > 1 && text.ToLower() == "refresh")
            {
                m_destinations.Clear();
                return(false);
            }

            if (Realm != eRealm.None && Realm != player.Realm && player.Client.Account.PrivLevel == (int)ePrivLevel.Player)
            {
                return(false);
            }

            Teleport destination = null;

            if (text == "Teleport")
            {
                int random    = Util.Random(1, m_destinations.Count);
                int newNumber = 1;
                foreach (Teleport t in m_destinations)
                {
                    if (newNumber == random)
                    {
                        destination = t;
                    }
                    else
                    {
                        newNumber += 1;
                    }
                }

                if (destination != null)
                {
                    OnDestinationPicked(player, destination);
                }
            }

            return(false);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Spawn a couple of nasty level 62-68 glimmer mobs 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 SpawnGlimmers(int numAdds, int x, int y)
        {
            GameNPC glimmer;

            for (int add = 0; add < numAdds; ++add)
            {
                glimmer = SpawnTimedAdd(624 + Util.Random(2), Util.Random(62, 68), x + Util.Random(250), y + Util.Random(250), 120, false);

                if (glimmer != null && glimmer.Brain is StandardMobBrain && Brain is DragonBrain)
                {
                    (Brain as DragonBrain).AddAggroListTo(glimmer.Brain as StandardMobBrain);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Invoked when retriever type mob has reached its target location.
        /// </summary>
        /// <param name="sender">The retriever mob.</param>
        public override void OnRetrieverArrived(GameNPC sender)
        {
            base.OnRetrieverArrived(sender);
            if (sender == null || sender == this)
            {
                return;
            }

            // Spawn nasty adds.
            if (m_messengerList.Contains(sender))
            {
                SpawnGlimmers(Util.Random(7, 10), sender.X, sender.Y);
            }
        }
Exemplo n.º 17
0
            public bool Init(GameClient Dealer, uint numDecks)
            {
                int i, j, tmp, swap;

                uint [] cards;
                Card    c;

                if (numDecks < 1)
                {
                    return(false);
                }

                /* Initialize Member Variables */
                m_dealer   = Dealer;
                m_numCards = numDecks * 52;

                /* Initialize the array of 'Cards' and the card queue */
                try{ cards = new uint[52 * numDecks]; m_Cards = new Queue((int)(52 * numDecks)); }
                catch (Exception) { return(false); }

                /* Initialize card IDs for numDecks */
                for (i = 0; i < numDecks; i++)
                {
                    for (j = 0; j < 52; j++)
                    {
                        cards[i * 52 + j] = (uint)j;
                    }
                }

                /* Decks have been initialized, shuffle them */
                j = (int)m_numCards;
                for (i = 0; i < m_numCards; i++)
                {
                    swap        = Util.Random(j - 1);
                    tmp         = (int)cards[i];
                    cards[i]    = cards[swap];
                    cards[swap] = (uint)tmp;
                }

                /* Place the cards in Queue */
                for (i = 0; i < m_numCards; i++)
                {
                    c = new Card();
                    c.Init(cards[i], false, m_dealer);
                    m_Cards.Enqueue(c);
                }

                /* OK */
                return(true);
            }
Exemplo n.º 18
0
        /// <summary>
        /// Invoked when retriever type mob has reached its target location.
        /// </summary>
        /// <param name="sender">The retriever mob.</param>
        public override void OnRetrieverArrived(GameNPC sender)
        {
            base.OnRetrieverArrived(sender);
            if (sender == null || sender == this)
            {
                return;
            }

            // Spawn nasty adds.

            if (m_retrieverList.Contains(sender))
            {
                SpawnDrakulvs(Util.Random(7, 10), sender.Position.X, sender.Position.Y);
            }
        }
Exemplo n.º 19
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.º 20
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.º 21
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.º 22
0
        /// <summary>
        /// Do a random emote.
        /// </summary>
        private void DoRandomEmote()
        {
            String[] emotes =
            {
                "The {0} seems to be making an extremely concerted effort not to start laughing hysterically.",
                "The {0} chuckles a bit to itself and mutters, 'Masters... hah...'",
                "The {0} giggles quietly and whispers to itself, 'That's right, go on, just a little further...'",
                "The {0} sounds as if it's quietly practicing to itself, 'What do you mean they didn't seem to be carrying any valuables?'",
                "The {0} mutters quietly, 'Now where did I put that scepter... oh well, I've dozens more now.'",
                "The {0} chuckles to itself and whispers, 'Oh I'll serve alright... serve just what you deserve.'"
            };

            foreach (GamePlayer player in GetPlayersInRadius(WorldMgr.SAY_DISTANCE))
            {
                player.Out.SendMessage(String.Format(emotes[Util.Random(emotes.GetUpperBound(0))], this.Name),
                                       eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
Exemplo n.º 23
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.º 24
0
        /// <summary>
        /// Hurl a player into the air.
        /// </summary>
        /// <param name="target">The player to hurl into the air.</param>
        private void ThrowLiving(GameLiving target)
        {
            BroadcastMessage(string.Format("{0} is hurled into the air!", target.Name));

            // Face the target, then push it 700 units up and 300 - 500 units backwards.
            TurnTo(target);

            Point3D targetPosition = PositionOfTarget(target, 700, Heading, Util.Random(300, 500));

            if (target is GamePlayer)
            {
                target.MoveTo(target.CurrentRegionID, targetPosition.X, targetPosition.Y, targetPosition.Z, target.Heading);
            }
            else if (target is GameNPC)
            {
                (target as GameNPC).MoveInRegion(target.CurrentRegionID, targetPosition.X, targetPosition.Y, targetPosition.Z, target.Heading, true);
                target.ChangeHealth(this, eHealthChangeType.Spell, (int)(target.Health * -0.35));
            }
        }
Exemplo n.º 25
0
 public void GiveRewards(GamePlayer player)
 {
     if (rewards == null)
     {
         return;
     }
     try
     {
         ItemTemplate[] array = new ItemTemplate[rewards.Count];
         if (array == null)
         {
             return;
         }
         int current = 0;
         foreach (ItemTemplate temp in rewards)
         {
             if ((player.Realm == (eRealm)temp.Realm) || (temp.Realm == 0))
             {
                 array[current] = temp;
                 current       += 1;
             }
         }
         InventoryItem item = GameInventoryItem.Create <ItemTemplate>(array[Util.Random(0, array.Length - 2)]);
         if (item != null)
         {
             if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
             {
                 player.Out.SendMessage("You receive " + item.GetName(0, false) + " from " + this.GetName(0, false) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow);
             }
             else
             {
                 player.CreateItemOnTheGround(item);
                 player.Out.SendMessage("Your Inventory is full. You couldn't recieve the " + item.Name + ", so it's been placed on the ground. Pick it up as soon as possible or it will vanish in a few minutes.", eChatType.CT_Important, eChatLoc.CL_PopupWindow);
             }
         }
         else
         {
             player.Out.SendMessage("There seems to be a bug with this chest!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
         }
     }
     catch { }
 }
Exemplo n.º 26
0
        /// <summary>
        /// Create an add from the specified template.
        /// </summary>
        /// <param name="templateID"></param>
        /// <param name="level"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="uptime"></param>
        /// <returns></returns>
        protected GameNPC SpawnTimedAdd(int templateID, int level, int x, int y, int uptime, bool isRetriever)
        {
            GameNPC add = null;

            try
            {
                if (m_addTemplate == null || m_addTemplate.TemplateId != templateID)
                {
                    m_addTemplate = NpcTemplateMgr.GetTemplate(templateID);
                }

                // Create add from template.
                // The add will automatically despawn after 30 seconds.
                if (m_addTemplate != null)
                {
                    add = new GameNPC(m_addTemplate);

                    if (isRetriever)
                    {
                        add.SetOwnBrain(new RetrieverMobBrain());
                    }

                    add.CurrentRegion   = CurrentRegion;
                    add.Heading         = (ushort)Util.Random(0, 4095);
                    add.Realm           = 0;
                    add.X               = x;
                    add.Y               = y;
                    add.Z               = Z;
                    add.CurrentSpeed    = 0;
                    add.Level           = (byte)level;
                    add.RespawnInterval = -1;
                    add.AddToWorld();
                    new DespawnTimer(this, add, uptime * 1000);
                }
            }
            catch
            {
                log.Warn(string.Format("Unable to get template for {0}", Name));
            }

            return(add);
        }
Exemplo n.º 27
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 token_many = new ItemTemplate(m_token_many);

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

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

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

                int maxcount = Util.Random(1, 10);
                loot.AddFixed(m_token_many, maxcount);
            }
            catch
            {
                return(loot);
            }

            return(loot);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Return the material yield for this salvage.
        /// </summary>
        public static int GetMaterialYield(GamePlayer player, InventoryItem item, SalvageYield salvageYield, ItemTemplate rawMaterial)
        {
            int maxCount = 0;

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

            if (ServerProperties.Properties.USE_NEW_SALVAGE)
            {
                maxCount = GetCountForSalvage(item, salvageYield, rawMaterial);
            }
            else
            {
                maxCount = (int)(item.Price * 0.45 / rawMaterial.Price);                 // crafted item return max 45% of the item value in material

                if (item.IsCrafted)
                {
                    maxCount = (int)Math.Ceiling((double)maxCount / 2);
                }
            }

            int playerPercent = player.GetCraftingSkillValue(CraftingMgr.GetSecondaryCraftingSkillToWorkOnItem(item)) * 100 / CraftingMgr.GetItemCraftLevel(item);

            if (playerPercent > 100)
            {
                playerPercent = 100;
            }
            else if (playerPercent < 75)
            {
                playerPercent = 75;
            }

            int minCount = (int)(((maxCount - 1) / 25f) * playerPercent) - ((3 * maxCount) - 4);             //75% => min = 1; 100% => min = maxCount;

            salvageYield.Count = Util.Random(minCount, maxCount);
            return(salvageYield.Count);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Called when the Relic has reached 0 XP and drops
        /// </summary>
        public virtual void RelicDispose()
        {
            if (timer != null)
            {
                timer.Dispose();
                timer = null;
            }

            if (Owner != null)
            {
                PlayerLoosesRelic(Owner, true);
            }

            RemoveFromWorld();

            if (respawntimer != null)
            {
                respawntimer.Stop();
                respawntimer = null;
            }
            respawntimer = new RegionTimer(this, new RegionTimerCallback(RespawnTimerCallback),
                                           Util.Random(MinotaurRelicManager.MIN_RESPAWN_TIMER, MinotaurRelicManager.MAX_RESPAWN_TIMER));
        }
Exemplo n.º 30
0
        /// <summary>
        /// Called when the Relic has reached 0 XP and drops
        /// </summary>
        public virtual void RelicDispose()
        {
            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }

            if (Owner != null)
            {
                PlayerLoosesRelic(Owner, true);
            }

            RemoveFromWorld();

            if (Respawntimer != null)
            {
                Respawntimer.Stop();
                Respawntimer = null;
            }

            Respawntimer = new RegionTimer(this, RespawnTimerCallback, Util.Random(MinotaurRelicManager.MinRespawnTimer, MinotaurRelicManager.MaxRespawnTimer));
        }