Ejemplo n.º 1
0
        public Mobile FindDispelTarget(bool activeOnly)
        {
            if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel)
            {
                return(null);
            }

            List <AggressorInfo> aggressed  = m_Mobile.Aggressed;
            List <AggressorInfo> aggressors = m_Mobile.Aggressors;

            Mobile active     = null;
            double activePrio = 0.0;

            Mobile comb = m_Mobile.Combatant as Mobile;

            if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, 12) && CanDispel(comb))
            {
                active     = comb;
                activePrio = m_Mobile.GetDistanceToSqrt(comb);

                if (activePrio <= 2)
                {
                    return(active);
                }
            }

            for (int i = 0; i < aggressed.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)aggressed[i];
                Mobile        m    = (Mobile)info.Defender;

                if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
                {
                    double prio = m_Mobile.GetDistanceToSqrt(m);

                    if (active == null || prio < activePrio)
                    {
                        active     = m;
                        activePrio = prio;

                        if (activePrio <= 2)
                        {
                            return(active);
                        }
                    }
                }
            }

            for (int i = 0; i < aggressors.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)aggressors[i];
                Mobile        m    = (Mobile)info.Attacker;

                if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
                {
                    double prio = m_Mobile.GetDistanceToSqrt(m);

                    if (active == null || prio < activePrio)
                    {
                        active     = m;
                        activePrio = prio;

                        if (activePrio <= 2)
                        {
                            return(active);
                        }
                    }
                }
            }

            return(active);
        }
Ejemplo n.º 2
0
        public Mobile FindDispelTarget(bool activeOnly)
        {
            if (this.m_Mobile.Deleted || this.m_Mobile.Int < 95 || this.CanDispel(this.m_Mobile) || this.m_Mobile.AutoDispel)
            {
                return(null);
            }

            if (activeOnly)
            {
                List <AggressorInfo> aggressed  = this.m_Mobile.Aggressed;
                List <AggressorInfo> aggressors = this.m_Mobile.Aggressors;

                Mobile active     = null;
                double activePrio = 0.0;

                Mobile comb = this.m_Mobile.Combatant;

                if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && this.m_Mobile.InRange(comb, Core.ML ? 10 : 12) && this.CanDispel(comb))
                {
                    active     = comb;
                    activePrio = this.m_Mobile.GetDistanceToSqrt(comb);

                    if (activePrio <= 2)
                    {
                        return(active);
                    }
                }

                for (int i = 0; i < aggressed.Count; ++i)
                {
                    AggressorInfo info = aggressed[i];
                    Mobile        m    = info.Defender;

                    if (m != comb && m.Combatant == this.m_Mobile && this.m_Mobile.InRange(m, Core.ML ? 10 : 12) && this.CanDispel(m))
                    {
                        double prio = this.m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                for (int i = 0; i < aggressors.Count; ++i)
                {
                    AggressorInfo info = aggressors[i];
                    Mobile        m    = info.Attacker;

                    if (m != comb && m.Combatant == this.m_Mobile && this.m_Mobile.InRange(m, Core.ML ? 10 : 12) && this.CanDispel(m))
                    {
                        double prio = this.m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                return(active);
            }
            else
            {
                Map map = this.m_Mobile.Map;

                if (map != null)
                {
                    Mobile active = null, inactive = null;
                    double actPrio = 0.0, inactPrio = 0.0;

                    Mobile comb = this.m_Mobile.Combatant;

                    if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && this.CanDispel(comb))
                    {
                        active  = inactive = comb;
                        actPrio = inactPrio = this.m_Mobile.GetDistanceToSqrt(comb);
                    }

                    foreach (Mobile m in this.m_Mobile.GetMobilesInRange(Core.ML ? 10 : 12))
                    {
                        if (m != this.m_Mobile && this.CanDispel(m))
                        {
                            double prio = this.m_Mobile.GetDistanceToSqrt(m);

                            if (!activeOnly && (inactive == null || prio < inactPrio))
                            {
                                inactive  = m;
                                inactPrio = prio;
                            }

                            if ((this.m_Mobile.Combatant == m || m.Combatant == this.m_Mobile) && (active == null || prio < actPrio))
                            {
                                active  = m;
                                actPrio = prio;
                            }
                        }
                    }

                    return(active != null ? active : inactive);
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
Archivo: CTF.cs Proyecto: jaedan/runuo
        public override bool OnDeath(Mobile mob, Container corpse)
        {
            Mobile killer = mob.FindMostRecentDamager(false);

            bool hadFlag = false;

            Item[] flags = corpse.FindItemsByType(typeof(CTFFlag), false);

            for (int i = 0; i < flags.Length; ++i)
            {
                (flags[i] as CTFFlag).DropTo(mob, killer);
            }

            hadFlag = (hadFlag || flags.Length > 0);

            if (mob.Backpack != null)
            {
                flags = mob.Backpack.FindItemsByType(typeof(CTFFlag), false);

                for (int i = 0; i < flags.Length; ++i)
                {
                    (flags[i] as CTFFlag).DropTo(mob, killer);
                }

                hadFlag = (hadFlag || flags.Length > 0);
            }

            if (killer != null && killer.Player)
            {
                CTFTeamInfo teamInfo = GetTeamInfo(killer);
                CTFTeamInfo victInfo = GetTeamInfo(mob);

                if (teamInfo != null && teamInfo != victInfo)
                {
                    CTFPlayerInfo playerInfo = teamInfo[killer];

                    if (playerInfo != null)
                    {
                        playerInfo.Kills += 1;
                        playerInfo.Score += 1; // base frag

                        if (hadFlag)
                        {
                            playerInfo.Score += 4; // fragged flag carrier
                        }
                        if (mob.InRange(teamInfo.Origin, 24) && mob.Map == this.Facet)
                        {
                            playerInfo.Score += 1; // fragged in base -- guarding
                        }
                        for (int i = 0; i < m_Controller.TeamInfo.Length; ++i)
                        {
                            if (m_Controller.TeamInfo[i] == teamInfo)
                            {
                                continue;
                            }

                            Mobile ourFlagCarrier = null;

                            if (m_Controller.TeamInfo[i].Flag != null)
                            {
                                ourFlagCarrier = m_Controller.TeamInfo[i].Flag.RootParent as Mobile;
                            }

                            if (ourFlagCarrier != null && GetTeamInfo(ourFlagCarrier) == teamInfo)
                            {
                                for (int j = 0; j < ourFlagCarrier.Aggressors.Count; ++j)
                                {
                                    AggressorInfo aggr = ourFlagCarrier.Aggressors[j] as AggressorInfo;

                                    if (aggr == null || aggr.Defender != ourFlagCarrier || aggr.Attacker != mob)
                                    {
                                        continue;
                                    }

                                    playerInfo.Score += 2; // helped defend guy capturing enemy flag
                                    break;
                                }

                                if (mob.Map == ourFlagCarrier.Map && ourFlagCarrier.InRange(mob, 12))
                                {
                                    playerInfo.Score += 1; // helped defend guy capturing enemy flag
                                }
                            }
                        }
                    }
                }
            }

            mob.CloseGump(typeof(CTFBoardGump));
            mob.SendGump(new CTFBoardGump(mob, this));

            m_Context.Requip(mob, corpse);
            DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse);

            return(false);
        }
Ejemplo n.º 4
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems)
            : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;          // protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            m_TimeOfDeath = DateTime.UtcNow;

            m_AccessLevel = owner.AccessLevel;
            m_Guild       = owner.Guild as Guild;
            m_Kills       = owner.Kills;
            SetFlag(CorpseFlag.Criminal, owner.Criminal);

            m_Hair       = hair;
            m_FacialHair = facialhair;

            // This corpse does not turn to bones if: the owner is not a player
            SetFlag(CorpseFlag.NoBones, !owner.Player);

            m_Looters    = new List <Mobile>();
            m_EquipItems = equipItems;

            m_Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);
            //bool addToAggressors = !( owner is BaseCreature );

            bool isBaseCreature = (owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (!isBaseCreature && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (!isBaseCreature)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (isBaseCreature)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.GetMaster();
                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                var rights = bc.GetLootingRights();
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);

            DevourCorpse();

            if (owner is PlayerMobile)
            {
                if (PlayerCorpses == null)
                {
                    PlayerCorpses = new Dictionary <Corpse, int>();
                }

                PlayerCorpses[this] = 0;
            }
        }
Ejemplo n.º 5
0
        public override bool DoOrderGuard()
        {
            if (m_Mobile.IsDeadPet)
            {
                return(true);
            }

            Mobile controlMaster = m_Mobile.ControlMaster;

            if (controlMaster == null || controlMaster.Deleted)
            {
                return(true);
            }

            Mobile combatant = m_Mobile.Combatant as Mobile;

            List <AggressorInfo> aggressors = controlMaster.Aggressors;

            if (aggressors.Count > 0)
            {
                for (int i = 0; i < aggressors.Count; ++i)
                {
                    AggressorInfo info     = aggressors[i];
                    Mobile        attacker = info.Attacker;

                    if (attacker != null && !attacker.Deleted && attacker.GetDistanceToSqrt(m_Mobile) <= m_Mobile.RangePerception)
                    {
                        if (combatant == null || attacker.GetDistanceToSqrt(controlMaster) < combatant.GetDistanceToSqrt(controlMaster))
                        {
                            if ((attacker is PlayerMobile && m_CanAttackPlayers) || !(attacker is PlayerMobile))
                            {
                                combatant = attacker;
                            }
                        }
                    }
                }

                if (combatant != null)
                {
                    m_Mobile.DebugSay("Crap, my master has been attacked! I will atack one of those bastards!");
                }
            }

            if (combatant != null && combatant != m_Mobile && combatant != m_Mobile.ControlMaster && !combatant.Deleted && combatant.Alive && !combatant.IsDeadBondedPet && m_Mobile.CanSee(combatant) && m_Mobile.CanBeHarmful(combatant, false) && combatant.Map == m_Mobile.Map)
            {
                m_Mobile.DebugSay("Guarding from target...");

                m_Mobile.Combatant = combatant;
                m_Mobile.FocusMob  = combatant;
                Action             = ActionType.Combat;

                /*
                 * We need to call Think() here or spell casting monsters will not use
                 * spells when guarding because their target is never processed.
                 */
                Think();
            }
            else
            {
                m_Mobile.DebugSay("Nothing to guard from");

                m_Mobile.Warmode = false;

                WalkMobileRange(controlMaster, 1, false, 0, 1);
            }

            return(true);
        }
Ejemplo n.º 6
0
        public Mobile FindDispelTarget(bool activeOnly)
        {
            if (m_Mobile.Deleted || !SmartAI || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel)
            {
                return(null);
            }

            if (activeOnly)
            {
                List <AggressorInfo> aggressed  = m_Mobile.Aggressed;
                List <AggressorInfo> aggressors = m_Mobile.Aggressors;

                Mobile active     = null;
                double activePrio = 0.0;

                Mobile comb = m_Mobile.Combatant;

                if (comb != null && !comb.Deleted && m_Mobile.InRange(comb, 12) && CanDispel(comb))
                {
                    active     = comb;
                    activePrio = m_Mobile.GetDistanceToSqrt(comb);

                    if (activePrio <= 2)
                    {
                        return(active);
                    }
                }

                for (int i = 0; i < aggressed.Count; ++i)
                {
                    AggressorInfo info = (AggressorInfo)aggressed[i];
                    Mobile        m    = (Mobile)info.Defender;

                    if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
                    {
                        double prio = m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                for (int i = 0; i < aggressors.Count; ++i)
                {
                    AggressorInfo info = (AggressorInfo)aggressors[i];
                    Mobile        m    = (Mobile)info.Attacker;

                    if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
                    {
                        double prio = m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                return(active);
            }
            else
            {
                Map map = m_Mobile.Map;

                if (map != null)
                {
                    Mobile active = null, inactive = null;
                    double actPrio = 0.0, inactPrio = 0.0;

                    Mobile comb = m_Mobile.Combatant;

                    if (comb != null && !comb.Deleted && CanDispel(comb))
                    {
                        active  = inactive = comb;
                        actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb);
                    }

                    foreach (Mobile m in m_Mobile.GetMobilesInRange(12))
                    {
                        if (m != m_Mobile && CanDispel(m))
                        {
                            double prio = m_Mobile.GetDistanceToSqrt(m);

                            if (!activeOnly && (inactive == null || prio < inactPrio))
                            {
                                inactive  = m;
                                inactPrio = prio;
                            }

                            if ((m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio))
                            {
                                active  = m;
                                actPrio = prio;
                            }
                        }
                    }

                    return(active != null ? active : inactive);
                }
            }

            return(null);
        }
Ejemplo n.º 7
0
        public Mobile FindDispelTarget(bool activeOnly)
        {
            if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel)
            {
                return(null);
            }

            if (activeOnly)
            {
                var aggressed  = m_Mobile.Aggressed;
                var aggressors = m_Mobile.Aggressors;

                Mobile active     = null;
                double activePrio = 0.0;

                Mobile comb = m_Mobile.Combatant as Mobile;

                if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, 12) &&
                    CanDispel(comb))
                {
                    active     = comb;
                    activePrio = m_Mobile.GetDistanceToSqrt(comb);

                    if (activePrio <= 2)
                    {
                        return(active);
                    }
                }

                for (int i = 0; i < aggressed.Count; ++i)
                {
                    AggressorInfo info = aggressed[i];
                    Mobile        m    = info.Defender;

                    if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
                    {
                        double prio = m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                for (int i = 0; i < aggressors.Count; ++i)
                {
                    AggressorInfo info = aggressors[i];
                    Mobile        m    = info.Attacker;

                    if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, 12) && CanDispel(m))
                    {
                        double prio = m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                return(active);
            }
            else
            {
                Map map = m_Mobile.Map;

                if (map != null)
                {
                    Mobile active = null, inactive = null;
                    double actPrio = 0.0, inactPrio = 0.0;

                    Mobile comb = m_Mobile.Combatant as Mobile;

                    if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb))
                    {
                        active  = inactive = comb;
                        actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb);
                    }

                    IPooledEnumerable eable = m_Mobile.GetMobilesInRange(12);

                    foreach (Mobile m in eable)
                    {
                        if (m != m_Mobile && CanDispel(m))
                        {
                            double prio = m_Mobile.GetDistanceToSqrt(m);

                            if (!activeOnly && (inactive == null || prio < inactPrio))
                            {
                                inactive  = m;
                                inactPrio = prio;
                            }

                            if ((m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio))
                            {
                                active  = m;
                                actPrio = prio;
                            }
                        }
                    }

                    eable.Free();

                    return(active != null ? active : inactive);
                }
            }

            return(null);
        }
Ejemplo n.º 8
0
        public Corpse(Mobile owner, ArrayList equipItems) : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;          // protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            m_TimeOfDeath = DateTime.Now;

            m_AccessLevel = owner.AccessLevel;
            m_Guild       = owner.Guild as Guild;
            m_Kills       = owner.Kills;
            m_Criminal    = owner.Criminal;

#if false
            // This corpse does not turn to bones if:
            //    (the owner is not a player) and (the owner doesn't have a human body)
            m_NoBones = !owner.Player && !owner.Body.IsHuman;
#else
            // This corpse does not turn to bones if:
            //    (the owner is not a player)
            m_NoBones = !owner.Player;
#endif

            m_Looters    = new ArrayList();
            m_EquipItems = equipItems;

            m_Aggressors = new ArrayList(owner.Aggressors.Count + owner.Aggressed.Count);
            bool addToAggressors = !(owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressors[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressed[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (!addToAggressors)
            {
                BaseCreature bc = (BaseCreature)owner;

                if (bc.Controlled && bc.ControlMaster != null)
                {
                    m_Aggressors.Add(bc.ControlMaster);
                }
                else if (bc.Summoned && bc.SummonMaster != null)
                {
                    m_Aggressors.Add(bc.SummonMaster);
                }

                ArrayList rights = BaseCreature.GetLootingRights(bc.DamageEntries);
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = (DamageStore)rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);
        }
Ejemplo n.º 9
0
        public void GiveCraftPowerScroll()              //Generate power scroll routine and add to pack
        {
            List <Mobile> toGive = new List <Mobile>(); //no idea :(

            List <AggressorInfo> list = Aggressors;     //I think it add list players that attacked it

            for (int i = 0; i < list.Count; ++i)
            {
                AggressorInfo info = list[i];

                if (info.Attacker.Player && info.Attacker.Alive && (DateTime.Now - info.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(info.Attacker))
                {
                    toGive.Add(info.Attacker);
                }
            }

            list = Aggressed;             //I think it add list of players it attacked
            for (int i = 0; i < list.Count; ++i)
            {
                AggressorInfo info = list[i];

                if (info.Defender.Player && info.Defender.Alive && (DateTime.Now - info.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(info.Defender))
                {
                    toGive.Add(info.Defender);
                }
            }
            if (toGive.Count == 0)              //if nobody attacked it and it didn't attack anybody then break operation and no ps MUAH
            {
                return;
            }

            // Randomize //absolutly no idea
            for (int i = 0; i < toGive.Count; ++i)
            {
                int    rand = Utility.Random(toGive.Count);
                Mobile hold = toGive[i];
                toGive[i]    = toGive[rand];
                toGive[rand] = hold;
            }

            PsCount = ChampionSpawn ? 5 : 2;             //set how many ps to give if it spawned using champ spawn or normal spawn
            for (int i = 0; i < PsCount; ++i)
            {
                Mobile m = (Mobile)toGive[i % toGive.Count];
                int    level;
                double random = Utility.RandomDouble();
                if (0.25 >= random)                   // select the level of the ps
                {
                    level = 120;
                }
                else if (0.55 >= random)
                {
                    level = 115;
                }
                else
                {
                    level = 110;
                }

                if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.RECIPE_CRAFT))
                {
                    m.AddToBackpack(new ResourceRecipe());
                }

                switch (Utility.Random(13))                                                   // select which skill to use in the ps
                {
                case 0: m.AddToBackpack(new PowerScroll(SkillName.Blacksmith, level)); break; // give blacksmith ps acording to the ps level we selected before

                case 1: m.AddToBackpack(new PowerScroll(SkillName.Tailoring, level)); break;

                case 2: m.AddToBackpack(new PowerScroll(SkillName.Tinkering, level)); break;

                case 3: m.AddToBackpack(new PowerScroll(SkillName.Mining, level)); break;

                case 4: m.AddToBackpack(new PowerScroll(SkillName.Carpentry, level)); break;

                case 5: m.AddToBackpack(new PowerScroll(SkillName.Alchemy, level)); break;

                case 6: m.AddToBackpack(new PowerScroll(SkillName.Fletching, level)); break;

                case 7: m.AddToBackpack(new PowerScroll(SkillName.Inscribe, level)); break;

                case 8: m.AddToBackpack(new PowerScroll(SkillName.Cooking, level)); break;

                case 9: m.AddToBackpack(new PowerScroll(SkillName.Cartography, level)); break;

                case 10: m.AddToBackpack(new PowerScroll(SkillName.Lumberjacking, level)); break;

                case 11: m.AddToBackpack(new PowerScroll(SkillName.Lockpicking, level)); break;

                case 12: m.AddToBackpack(new PowerScroll(SkillName.Fishing, level)); break;
                }
                m.SendLocalizedMessage(1049524);                                                         // You have received a scroll of power!
                if (Utility.Random(1) == 0)                                                              //Select random number between 0-4 and if it's 2 continue
                {
                    switch (Utility.Random(47))                                                          //select random number between 0-46
                    {
                    case 0: m.AddToBackpack(new RunicFletcherTools(CraftResource.Heartwood, 10)); break; // pine runic fletcher tool with 10 charges

                    case 1: m.AddToBackpack(new RunicFletcherTools(CraftResource.Bloodwood, 10)); break;

                    case 2: m.AddToBackpack(new RunicFletcherTools(CraftResource.Frostwood, 10)); break;

                    case 3: m.AddToBackpack(new RunicFletcherTools(CraftResource.OakWood, 10)); break;

                    case 4: m.AddToBackpack(new RunicFletcherTools(CraftResource.AshWood, 10)); break;

                    case 5: m.AddToBackpack(new RunicFletcherTools(CraftResource.YewWood, 10)); break;

                    case 6: m.AddToBackpack(new RunicFletcherTools(CraftResource.Ebony, 10)); break;

                    case 7: m.AddToBackpack(new RunicFletcherTools(CraftResource.Bamboo, 10)); break;

                    case 8: m.AddToBackpack(new RunicFletcherTools(CraftResource.PurpleHeart, 10)); break;

                    case 9: m.AddToBackpack(new RunicFletcherTools(CraftResource.Redwood, 10)); break;

                    case 10: m.AddToBackpack(new RunicFletcherTools(CraftResource.Petrified, 10)); break;

                    case 11: m.AddToBackpack(new RunicHammer(CraftResource.DullCopper, 10)); break;                                 // Dull Copper runic hamemr with 10 charges

                    case 12: m.AddToBackpack(new RunicHammer(CraftResource.ShadowIron, 10)); break;

                    case 13: m.AddToBackpack(new RunicHammer(CraftResource.Copper, 10)); break;

                    case 14: m.AddToBackpack(new RunicHammer(CraftResource.Bronze, 10)); break;

                    case 15: m.AddToBackpack(new RunicHammer(CraftResource.Gold, 10)); break;

                    case 16: m.AddToBackpack(new RunicHammer(CraftResource.Agapite, 10)); break;

                    case 17: m.AddToBackpack(new RunicHammer(CraftResource.Verite, 10)); break;

                    case 18: m.AddToBackpack(new RunicHammer(CraftResource.Valorite, 10)); break;

                    case 19: m.AddToBackpack(new RunicHammer(CraftResource.Blaze, 10)); break;

                    case 20: m.AddToBackpack(new RunicHammer(CraftResource.Ice, 10)); break;

                    case 21: m.AddToBackpack(new RunicHammer(CraftResource.Toxic, 10)); break;

                    case 22: m.AddToBackpack(new RunicHammer(CraftResource.Electrum, 10)); break;

                    case 23: m.AddToBackpack(new RunicHammer(CraftResource.Platinum, 10)); break;

                    case 24: m.AddToBackpack(new RunicSewingKit(CraftResource.SpinedLeather, 10)); break;                                 // Spined Leather runic sewing kit with 10 charges

                    case 25: m.AddToBackpack(new RunicSewingKit(CraftResource.HornedLeather, 10)); break;

                    case 26: m.AddToBackpack(new RunicSewingKit(CraftResource.BarbedLeather, 10)); break;

                    case 27: m.AddToBackpack(new RunicSewingKit(CraftResource.PolarLeather, 10)); break;

                    case 28: m.AddToBackpack(new RunicSewingKit(CraftResource.SyntheticLeather, 10)); break;

                    case 29: m.AddToBackpack(new RunicSewingKit(CraftResource.BlazeLeather, 10)); break;

                    case 30: m.AddToBackpack(new RunicSewingKit(CraftResource.DaemonicLeather, 10)); break;

                    case 31: m.AddToBackpack(new RunicSewingKit(CraftResource.ShadowLeather, 10)); break;

                    case 32: m.AddToBackpack(new RunicSewingKit(CraftResource.FrostLeather, 10)); break;

                    case 33: m.AddToBackpack(new RunicSewingKit(CraftResource.EtherealLeather, 10)); break;

                    case 34: m.AddToBackpack(new RunicTinkerTools(CraftResource.DullCopper, 10)); break;                                 // Dull Copper runic hamemr with 10 charges

                    case 35: m.AddToBackpack(new RunicTinkerTools(CraftResource.ShadowIron, 10)); break;

                    case 36: m.AddToBackpack(new RunicTinkerTools(CraftResource.Copper, 10)); break;

                    case 37: m.AddToBackpack(new RunicTinkerTools(CraftResource.Bronze, 10)); break;

                    case 38: m.AddToBackpack(new RunicTinkerTools(CraftResource.Gold, 10)); break;

                    case 39: m.AddToBackpack(new RunicTinkerTools(CraftResource.Agapite, 10)); break;

                    case 40: m.AddToBackpack(new RunicTinkerTools(CraftResource.Verite, 10)); break;

                    case 41: m.AddToBackpack(new RunicTinkerTools(CraftResource.Valorite, 10)); break;

                    case 42: m.AddToBackpack(new RunicTinkerTools(CraftResource.Blaze, 10)); break;

                    case 43: m.AddToBackpack(new RunicTinkerTools(CraftResource.Ice, 10)); break;

                    case 44: m.AddToBackpack(new RunicTinkerTools(CraftResource.Toxic, 10)); break;

                    case 45: m.AddToBackpack(new RunicTinkerTools(CraftResource.Electrum, 10)); break;

                    case 46: m.AddToBackpack(new RunicTinkerTools(CraftResource.Platinum, 10)); break;
                    }
                    m.SendMessage("You have recieved a runic tool.");
                }
            }
        }