Exemplo n.º 1
0
        public void AddDespisePoints(Mobile from, PutridHeart heart)
        {
            if (!m_PointsTable.ContainsKey(from))
            {
                m_PointsTable[from] = 0;
            }

            int amount = heart.Amount;

            m_PointsTable[from] += amount;
            from.SendLocalizedMessage(1153423, amount.ToString()); // You have gained ~1_AMT~ Dungeon Crystal Points of Despise.
            heart.Delete();
        }
Exemplo n.º 2
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>();

                foreach (DamageEntry de in despiseCreature.DamageEntries)
                {
                    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));
        }