示例#1
0
        public static bool CalcAwardInSilver(Mobile m, out int silver, out int gold)
        {
            // new award amounts
            silver = gold = 0;

            if (m == null || m is BaseCreature == false)
            {
                return(false);
            }

            BaseCreature bc = m as BaseCreature;

            // creature must be IOB aligned
            if (IOBSystem.IsIOBAligned(bc) == false)
            {
                return(false);
            }

            //creature must not be controlled
            if (bc.ControlMaster != null)
            {
                return(false);
            }

            // first find out how much gold this creature is dropping as that will be the gauge for the silver drop
            int MobGold = bc.GetGold();

            // meh, random I know
            gold   = MobGold / 2;               // cut the gold in half
            silver = MobGold / 10;              // and give him 10% in silver

            // now calc the damagers.
            bool         fail    = false;
            ArrayList    list    = BaseCreature.GetLootingRights(bc.DamageEntries);
            IOBAlignment IOBBase = IOBAlignment.None;

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

                if (!ds.m_HasRight)
                {
                    continue;
                }

                if (ds.m_Mobile != null)
                {
                    // initialize the required IOBAlignment (one time)
                    if (IOBBase == IOBAlignment.None)
                    {
                        IOBBase = IOBSystem.GetIOBAlignment(ds.m_Mobile);
                    }

                    // ds.m_Mobile may be a basecreature or a playermobile
                    // 1. if the damager is not an ememy of the creature it killed, then no silver awards
                    // 2. if all damagers are not of the same alignment, then no silver awards
                    // 3. if the top damager was an interferer, no silver awards
                    if (IOBSystem.IsEnemy(ds.m_Mobile, m) == false || IOBBase != IOBSystem.GetIOBAlignment(ds.m_Mobile) || IOBBase == IOBAlignment.Healer)
                    {                           // no silver awards
                        fail = true;
                        break;
                    }
                }
            }

            // see if there were any non same-kin damagers.
            //	we won't reward silver if there was outside help
            if (fail == true)
            {
                return(false);
            }


            // okay, we have new amounts
            return(true);
        }