Esempio n. 1
0
        private Mobile GetFocus(IPoint3D p, int range)
        {
            IPooledEnumerable eable = m_Creature.Map.GetMobilesInRange(new Point3D(p), range);
            Mobile            focus = null;
            int dist = range;

            foreach (Mobile m in eable)
            {
                if (m is DespiseCreature)
                {
                    DespiseCreature dc = m as DespiseCreature;

                    if (dc.Orb == null && !dc.Controlled && dc.Alignment != Alignment.Neutral && dc.Alignment != m_Creature.Alignment)
                    {
                        int distance = (int)m_Creature.GetDistanceToSqrt(dc);

                        if (focus == null || distance < dist)
                        {
                            focus = dc;
                            dist  = distance;
                        }
                    }
                }
                else if (m is DespiseBoss)
                {
                    focus = m;
                    break;
                }
            }

            eable.Free();

            return(focus);
        }
Esempio n. 2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int v = reader.ReadInt();

            m_Owner       = reader.ReadMobile();
            m_Pet         = reader.ReadMobile() as DespiseCreature;
            m_LeashLength = (LeashLength)reader.ReadInt();
            m_Aggression  = (Aggression)reader.ReadInt();
            m_Alignment   = (Alignment)reader.ReadInt();
            m_Conscripted = reader.ReadBool();

            switch (reader.ReadInt())
            {
            case 0: break;

            case 1: m_Anchor = reader.ReadMobile(); break;

            case 2: m_Anchor = reader.ReadItem(); break;
            }

            if (m_Anchor == null && m_Pet != null)
            {
                Anchor = m_Owner;
            }

            m_Orbs.Add(this);
        }
Esempio n. 3
0
 public void OnUnlinkPet()
 {
     m_Pet        = null;
     m_Anchor     = null;
     m_Aggression = Aggression.Aggressive;
     InvalidateProperties();
 }
Esempio n. 4
0
        private Mobile GetFocus(IPoint3D p, int range)
        {
            IPooledEnumerable eable = m_Creature.Map.GetMobilesInRange(new Point3D(p), range);
            Mobile            focus = null;
            int dist = range;

            foreach (Mobile m in eable)
            {
                if (m_Creature.CanSee(m) && m_Creature.InLOS(m) && (m is DespiseCreature || m is DespiseBoss))
                {
                    DespiseCreature dc = m as DespiseCreature;

                    if (m is DespiseBoss || dc.Orb == null && !dc.Controlled || dc.Alignment != m_Creature.Alignment)
                    {
                        int distance = (int)m_Creature.GetDistanceToSqrt(m);

                        if (focus == null || distance < dist)
                        {
                            focus = m;
                            dist  = distance;
                        }
                    }
                }
            }

            eable.Free();
            return(focus);
        }
Esempio n. 5
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is BaseCreature)
                {
                    DespiseCreature creature = targeted as DespiseCreature;

                    if (creature == null)
                    {
                        from.SendLocalizedMessage(1153286); // That cannot be possessed by a Wisp Orb.
                    }
                    else if (m_Orb.Pet == null)
                    {
                        if (((BaseCreature)targeted).Controlled)
                        {
                            from.SendLocalizedMessage(1153287); // That creature is already under the control of a Wisp Orb.
                        }
                        else if (creature.Power > 5)
                        {
                            from.SendLocalizedMessage(1153336); // That creature is too powerful for you to coerce.
                        }
                        else
                        {
                            m_Orb.Anchor = from;

                            m_Orb.Pet = creature;
                            creature.Link(m_Orb);

                            m_Orb.Pet.SetControlMaster(from);
                            m_Orb.Pet.ControlTarget = from;
                            m_Orb.Pet.ControlOrder  = OrderType.Follow;

                            from.SendLocalizedMessage(1153276);                                              // Your Wisp Orb takes control of the creature!
                            m_Orb.Pet.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1153295, from.Name); // * This creature is now under the control of ~1_NAME~ *
                        }
                    }
                    else if (targeted == m_Orb.Pet)
                    {
                        int aggr = (int)m_Orb.Aggression + 1;
                        if (aggr >= 2)
                        {
                            aggr = 0;
                        }

                        m_Orb.Aggression = (Aggression)aggr;

                        from.SendLocalizedMessage(1153279, m_Orb.Aggression.ToString()); // Your possessed creature's aggression level is now: ~1_VAL~
                    }
                    else
                    {
                        m_Orb.TrySetAnchor(from, (BaseCreature)targeted);
                    }
                }
                else if (targeted == m_Orb)
                {
                    int length = (int)m_Orb.LeashLength + 1;
                    if (length >= 2)
                    {
                        length = 0;
                    }

                    m_Orb.LeashLength = (LeashLength)length;

                    from.SendLocalizedMessage(1153278, m_Orb.LeashLength.ToString()); // Your possessed creature's leash is now: ~1_VAL~
                }
                else if (targeted is IPoint3D && m_Orb.Pet != null)
                {
                    m_Orb.TrySetAnchor(from, (IPoint3D)targeted);
                }
            }
Esempio n. 6
0
        public override bool OnBeforeDeath(Mobile m)
        {
            if (m is DespiseCreature && m.Region != null && m.Region.IsPartOf(this.GetType()))
            {
                DespiseCreature dc = (DespiseCreature)m;

                if (!dc.Controlled && dc.Orb == null)
                {
                    Dictionary <DespiseCreature, int> creatures = new Dictionary <DespiseCreature, int>();

                    foreach (DamageEntry de in m.DamageEntries)
                    {
                        if (de.Damager is DespiseCreature)
                        {
                            DespiseCreature creat = de.Damager as DespiseCreature;

                            if (!creat.Controlled || creat.Orb == null)
                            {
                                continue;
                            }

                            if (creatures.ContainsKey(creat))
                            {
                                creatures[creat] += de.DamageGiven;
                            }
                            else
                            {
                                creatures[creat] = de.DamageGiven;
                            }
                        }
                    }

                    if (creatures.Count > 0)
                    {
                        DespiseCreature topdam  = null;
                        int             highest = 0;

                        foreach (KeyValuePair <DespiseCreature, int> kvp in creatures)
                        {
                            if (topdam == null || kvp.Value > highest)
                            {
                                topdam  = kvp.Key;
                                highest = kvp.Value;
                            }
                        }

                        if (topdam != null && highest > 0)
                        {
                            int mobKarma = Math.Abs(dc.Karma);
                            int karma    = (int)(((double)mobKarma / 10) * (double)highest / (double)dc.HitsMax);

                            if (karma < 1)
                            {
                                karma = 1;
                            }

                            if (dc.Karma > 0)
                            {
                                karma *= -1;
                            }

                            Mobile    master   = topdam.GetMaster();
                            Alignment oldAlign = topdam.Alignment;
                            int       power    = topdam.Power;
                            topdam.Karma += karma;
                            Alignment newAlign = topdam.Alignment;

                            if (master != null && karma > 0)
                            {
                                master.SendLocalizedMessage(1153281); // Your possessed creature has gained karma!
                            }
                            else if (master != null && karma < 0)
                            {
                                master.SendLocalizedMessage(1153282); // Your possessed creature has lost karma!
                            }
                            if (power < topdam.MaxPower)
                            {
                                topdam.Progress += dc.Power;

                                if (topdam.Power > power && master != null)
                                {
                                    master.SendLocalizedMessage(1153293, topdam.Name); // ~1_NAME~ is growing in strength.
                                }
                            }
                            else if (master != null)
                            {
                                master.SendLocalizedMessage(1153309); // Your controlled creature cannot gain further power.
                            }
                            if (oldAlign != newAlign && newAlign != Alignment.Neutral && topdam.MaxPower < 15)
                            {
                                topdam.MaxPower = 15;

                                if (master != null)
                                {
                                    master.SendLocalizedMessage(1153294, topdam.Name); // ~1_NAME~ has achieved a new threshold in power!
                                }
                                topdam.Delta(MobileDelta.Noto);

                                topdam.FixedEffect(0x373A, 10, 30);
                                topdam.PlaySound(0x209);
                            }
                        }
                    }

                    int amount = Utility.RandomMinMax(dc.Power * 8, dc.Power * 10);
                    dc.PackItem(new PutridHeart(amount));
                }
            }

            return(base.OnBeforeDeath(m));
        }
Esempio n. 7
0
 public DespiseMageAI(DespiseCreature m)
     : base(m)
 {
     m_Creature = m;
 }
Esempio n. 8
0
        public override bool OnBeforeDeath(Mobile m)
        {
            if (m is DespiseCreature despiseCreature && despiseCreature.Region != null && despiseCreature.Region.IsPartOf(GetType()) && !despiseCreature.Controlled && despiseCreature.Orb == null)
            {
                Dictionary <DespiseCreature, int> creatures = new Dictionary <DespiseCreature, int>();

                for (var index = 0; index < despiseCreature.DamageEntries.Count; index++)
                {
                    DamageEntry de = despiseCreature.DamageEntries[index];

                    if (de.Damager is DespiseCreature creat)
                    {
                        if (!creat.Controlled || creat.Orb == null)
                        {
                            continue;
                        }

                        if (creatures.ContainsKey(creat))
                        {
                            creatures[creat] += de.DamageGiven;
                        }
                        else
                        {
                            creatures[creat] = de.DamageGiven;
                        }
                    }
                }

                if (creatures.Count > 0)
                {
                    DespiseCreature topdam  = null;
                    int             highest = 0;

                    foreach (KeyValuePair <DespiseCreature, int> kvp in creatures)
                    {
                        if (topdam == null || kvp.Value > highest)
                        {
                            topdam  = kvp.Key;
                            highest = kvp.Value;
                        }
                    }

                    if (topdam != null && highest > 0)
                    {
                        int mobKarma = Math.Abs(despiseCreature.Karma);
                        int karma    = (int)((double)mobKarma / 10 * highest / despiseCreature.HitsMax);

                        if (karma < 1)
                        {
                            karma = 1;
                        }

                        if (despiseCreature.Karma > 0)
                        {
                            karma *= -1;
                        }

                        Mobile    master   = topdam.GetMaster();
                        Alignment oldAlign = topdam.Alignment;
                        int       power    = topdam.Power;
                        topdam.Karma += karma;
                        Alignment newAlign = topdam.Alignment;

                        if (master != null && karma > 0)
                        {
                            master.SendLocalizedMessage(1153281); // Your possessed creature has gained karma!
                        }
                        else if (master != null && karma < 0)
                        {
                            master.SendLocalizedMessage(1153282); // Your possessed creature has lost karma!
                        }
                        if (power < topdam.MaxPower)
                        {
                            topdam.Progress += despiseCreature.Power;

                            if (topdam.Power > power && master != null)
                            {
                                master.SendLocalizedMessage(1153294,
                                                            topdam.Name); // ~1_NAME~ has achieved a new threshold in power!
                            }
                        }
                        else if (master != null)
                        {
                            master.SendLocalizedMessage(1153309); // Your controlled creature cannot gain further power.
                        }
                        if (oldAlign != newAlign && newAlign != Alignment.Neutral && topdam.MaxPower < 15)
                        {
                            topdam.MaxPower = 15;

                            if (master != null)
                            {
                                master.SendLocalizedMessage(1153293, topdam.Name); // ~1_NAME~ is growing in strength.
                            }
                            topdam.Delta(MobileDelta.Noto);

                            topdam.FixedEffect(0x373A, 10, 30);
                            topdam.PlaySound(0x209);
                        }

                        if (master != null && master.Map != null && master.Map != Map.Internal &&
                            master.Backpack != null)
                        {
                            PutridHeart heart = new PutridHeart(Utility.RandomMinMax(despiseCreature.Power * 8,
                                                                                     despiseCreature.Power * 10));

                            if (!master.Backpack.TryDropItem(master, heart, false))
                            {
                                heart.MoveToWorld(master.Location, master.Map);
                            }
                        }
                    }
                }
            }

            return(base.OnBeforeDeath(m));
        }
Esempio n. 9
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);
			int v = reader.ReadInt();
			
			m_Owner = reader.ReadMobile();
			m_Pet = reader.ReadMobile() as DespiseCreature;
			m_LeashLength = (LeashLength)reader.ReadInt();
			m_Aggression = (Aggression)reader.ReadInt();
			m_Alignment = (Alignment)reader.ReadInt();
            m_Conscripted = reader.ReadBool();

            switch (reader.ReadInt())
            {
                case 0: break;
                case 1: m_Anchor = (IPoint3D)reader.ReadMobile(); break;
                case 2: m_Anchor = (IPoint3D)reader.ReadPoint3D(); break;
            }

            if (m_Anchor == null && m_Pet != null)
                m_Pet.Home = m_Pet.Location;

			m_Orbs.Add(this);
		}
Esempio n. 10
0
 public void OnUnlinkPet()
 {
     m_Pet = null;
     m_Anchor = null;
     m_Aggression = Aggression.Following;
     InvalidateProperties();
 }
Esempio n. 11
0
 public DespiseMageAI(DespiseCreature m) : base(m)
 {
     m_Creature = m;
 }