コード例 #1
0
ファイル: Mobile.cs プロジェクト: BackupTheBerlios/sunuo-svn
        public virtual DamageEntry RegisterDamage( int amount, Mobile from )
        {
            DamageEntry de = FindDamageEntryFor( from );

            if ( de == null )
                de = new DamageEntry( from );

            de.DamageGiven += amount;
            de.LastDamage = Core.Now;

            m_DamageEntries.Remove( de );
            m_DamageEntries.Add( de );

            Mobile master = from.GetDamageMaster( this );

            if ( master != null )
            {
                ArrayList list = de.Responsible;

                if ( list == null )
                    de.Responsible = list = new ArrayList();

                DamageEntry resp = null;

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

                    if ( check.Damager == master )
                    {
                        resp = check;
                        break;
                    }
                }

                if ( resp == null )
                    list.Add( resp = new DamageEntry( master ) );

                resp.DamageGiven += amount;
                resp.LastDamage = Core.Now;
            }

            return de;
        }
コード例 #2
0
ファイル: Harrower.cs プロジェクト: zerodowned/angelisland
        private void GiveMagicItems()
        {
            ArrayList toGive = new ArrayList();

            LogHelper Logger = new LogHelper("HarrowerLoot.log", false);


            ArrayList allNonExpiredPMDamageEntries = new ArrayList();
            //New Looting method (Pix: 4/8/06)
            for (int i = 0; i < DamageEntries.Count; i++)
            {
                DamageEntry de = DamageEntries[i] as DamageEntry;
                if (de != null)
                {
                    Logger.Log(LogType.Text, string.Format("DE[{0}]: {1} ({2})", i, de.Damager, de.Damager != null ? de.Damager.Name : ""));
                    if (de.HasExpired)
                    {
                        Logger.Log(LogType.Text, string.Format("DE[{0}]: Expired", i));
                    }
                    else
                    {
                        if (de.Damager != null && !de.Damager.Deleted)
                        {
                            if (de.Damager is BaseCreature)
                            {
                                Logger.Log(LogType.Text, string.Format("DE[{0}]: BaseCreature", i));
                                BaseCreature bc = (BaseCreature)de.Damager;
                                if (bc.ControlMaster != null && !bc.ControlMaster.Deleted)
                                {
                                    //de.Damager = bc.ControlMaster;
                                    DamageEntry cmde = new DamageEntry(bc.ControlMaster);
                                    cmde.DamageGiven = de.DamageGiven;
                                    de = cmde;
                                    Logger.Log(LogType.Text, string.Format("DE[{0}]: New Damager: {1}", i, de.Damager.Name));
                                }
                            }

                            if (de.Damager is PlayerMobile)
                            {
                                Logger.Log(LogType.Text, string.Format("DE[{0}]: PlayerMobile", i));

                                if (de.Damager.Alive)
                                {
                                    Logger.Log(LogType.Text, string.Format("DE[{0}]: PM Alive", i));

                                    bool bFound = false;
                                    for (int j = 0; j < allNonExpiredPMDamageEntries.Count; j++)
                                    {
                                        DamageEntry de2 = (DamageEntry)allNonExpiredPMDamageEntries[j];
                                        if (de2.Damager == de.Damager)
                                        {
                                            Logger.Log(LogType.Text, string.Format("DE[{0}]: PM Found, adding damage", i));

                                            de2.DamageGiven += de.DamageGiven;
                                            bFound = true;
                                            break;
                                        }
                                    }

                                    if (!bFound)
                                    {
                                        Logger.Log(LogType.Text, string.Format("DE[{0}]: PM not found, adding", i));
                                        allNonExpiredPMDamageEntries.Add(de);
                                    }
                                }
                            }

                        }
                    }
                }
            }

            //Remove any PMs that are over 100 tiles away
            ArrayList toRemove = new ArrayList();
            for (int i = 0; i < allNonExpiredPMDamageEntries.Count; i++)
            {
                DamageEntry de = (DamageEntry)allNonExpiredPMDamageEntries[i];
                if (de.Damager.GetDistanceToSqrt(this.Location) > 100)
                {
                    Logger.Log(LogType.Text, string.Format("Removing {0} for being too far away at death", de.Damager.Name));
                    toRemove.Add(allNonExpiredPMDamageEntries[i]);
                }
            }
            for (int i = 0; i < toRemove.Count; i++)
            {
                allNonExpiredPMDamageEntries.Remove(toRemove[i]);
            }

            int topDamage = 0;
            int minDamage = 0;
            for (int i = 0; i < allNonExpiredPMDamageEntries.Count; i++)
            {
                DamageEntry de = (DamageEntry)allNonExpiredPMDamageEntries[i];
                if (de.DamageGiven > topDamage) topDamage = de.DamageGiven;

                Logger.Log(LogType.Text, string.Format("Non-Expired[{0}]: {1} (damage: {2})", i, de.Damager.Name, de.DamageGiven));

            }

            //Now filter on 'enough' damage
            if (HitsMax >= 3000) minDamage = topDamage / 16;
            else if (HitsMax >= 1000) minDamage = topDamage / 8;
            else if (HitsMax >= 200) minDamage = topDamage / 4;
            else minDamage = topDamage / 2;

            Logger.Log(LogType.Text, string.Format("HitsMax: {0}, TopDamage: {1}, MinDamage: {2}", HitsMax, topDamage, minDamage));


            for (int i = 0; i < allNonExpiredPMDamageEntries.Count; i++)
            {
                DamageEntry de = (DamageEntry)allNonExpiredPMDamageEntries[i];
                if (de.DamageGiven >= minDamage)
                {
                    toGive.Add(de.Damager);
                }
            }


            if (toGive.Count == 0)
                return;

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

            Logger.Log(LogType.Text, ""); // new line
            Logger.Log(LogType.Text, "Randomized list of players:");
            for (int i = 0; i < toGive.Count; ++i)
            {
                Mobile mob = toGive[i] as Mobile;
                Logger.Log(LogType.Mobile, mob, "alive:" + mob.Alive.ToString());
            }

            Logger.Log(LogType.Text, ""); // new line
            Logger.Log(LogType.Text, "Begin loot distribution: Who/What:");

            // Loop goes until we've generated MaxGifts items.
            for (int i = 0; i < MaxGifts; ++i)
            {
                Item reward = null;
                Mobile m = (Mobile)toGive[i % toGive.Count];

                switch (Utility.Random(10))
                {
                    case 0:			// Power/Vanq Weapon
                    case 1:
                    case 2:	// 3 in 10 chance	
                        {	// 33% chance at best
                            reward = CreateWeapon((0.32 >= Utility.RandomDouble()) ? 5 : 4);
                            break;
                        }
                    case 3:			// Fort/Invul Armor
                    case 4:
                    case 5:	// 3 in 10 chance 
                        {	// 33% chance at best
                            reward = CreateArmor((0.32 >= Utility.RandomDouble()) ? 5 : 4);
                            break;
                        }
                    case 6:		// hair/beard dye
                        {		// 1 in 10 chance
                            if (Utility.RandomBool())
                                reward = new SpecialHairDye();
                            else
                                reward = new SpecialBeardDye();
                            break;
                        }
                    case 7:		// special cloth
                        {		// 1 in 10 chance
                            reward = new UncutCloth(50);
                            if (Utility.RandomBool())
                                // best ore hues (vet rewards) + really dark 'evil cloth'
                                reward.Hue = Utility.RandomList(2213, 2219, 2207, 2425, 1109);
                            else
                                reward.Hue = 0x01;	// black cloth
                            break;
                        }

                    case 8:		// potted plant
                        {		// 1 in 10 chance
                            switch (Utility.Random(11))
                            {
                                default:	// should never happen
                                case 0: reward = new PottedCactus(); break;
                                case 1: reward = new PottedCactus1(); break;
                                case 2: reward = new PottedCactus2(); break;
                                case 3: reward = new PottedCactus3(); break;
                                case 4: reward = new PottedCactus4(); break;
                                case 5: reward = new PottedCactus5(); break;
                                case 6: reward = new PottedPlant(); break;
                                case 7: reward = new PottedPlant1(); break;
                                case 8: reward = new PottedPlant2(); break;
                                case 9: reward = new PottedTree(); break;
                                case 10: reward = new PottedTree1(); break;
                            }
                            break;
                        }

                    default:	// Should never happen
                    /* fall through*/

                    case 9:		// Magic Item Drop
                        {			// 1 in 10 chance
                            reward = Loot.RandomClothingOrJewelry();
                            if (reward != null)
                            {
                                int minLevel = 3;
                                int maxLevel = 3;
                                if (reward is BaseClothing)
                                    ((BaseClothing)reward).SetRandomMagicEffect(minLevel, maxLevel);
                                else if (reward is BaseJewel)
                                    ((BaseJewel)reward).SetRandomMagicEffect(minLevel, maxLevel);
                            }
                            break;
                        }
                }

                if (reward != null)
                {
                    // Drop the new weapon into their backpack and send them a message.
                    m.SendMessage("You have received a special item!");
                    m.AddToBackpack(reward);

                    Logger.Log(LogType.Mobile, m, "alive:" + m.Alive.ToString());
                    Logger.Log(LogType.Item, reward, string.Format("Hue:{0}:Rare:{1}",
                        reward.Hue,
                        (reward is BaseWeapon || reward is BaseArmor || reward is BaseClothing || reward is BaseJewel) ? "False" : "True"));
                }
            }

            // done logging
            Logger.Finish();
        }
コード例 #3
0
ファイル: Mobile.cs プロジェクト: BackupTheBerlios/sunuo-svn
 public static Mobile GetDamagerFrom( DamageEntry de )
 {
     return ( de == null ? null : de.Damager );
 }
コード例 #4
0
		public bool HasExpired(DamageEntry de)
		{
		       return(de.LastDamage + TimeSpan.FromMinutes(5.0) < DateTime.Now);
		}