Exemple #1
0
        // this method returns a list of the group types that the mobile belongs to using the KillGroups master list
        public static List <GroupTypes> FindGroups(Mobile m)
        {
            if (m == null)
            {
                return(null);
            }

            List <GroupTypes> list;

            // see whether this mobile type is already in the dictionary
            if (GroupTypeHash.TryGetValue(m.GetType(), out list) && list != null)
            {
                // then get the list from there
                return(GroupTypeHash[m.GetType()]);
            }

            list = new List <XmlMobFactions.GroupTypes>();

            foreach (Group g in KillGroups)
            {
                if (MatchType(g.Members, m))
                {
                    list.Add(g.GroupType);
                }
            }
            GroupTypeHash[m.GetType()] = list;

            return(list);
        }
Exemple #2
0
        // this method returns a list of the group types that the mobile belongs to using the KillGroups master list
        public static ArrayList FindGroups(Mobile m)
        {
            if (m == null)
            {
                return(null);
            }

            // see whether this mobile type is already in the hash table
            if (GroupTypeHash.Contains(m.GetType()))
            {
                // then get the list from there
                return((ArrayList)GroupTypeHash[m.GetType()]);
            }

            ArrayList list = new ArrayList();

            foreach (Group g in KillGroups)
            {
                if (MatchType(g.Members, m))
                {
                    list.Add(g.GroupType);
                }
            }
            GroupTypeHash.Add(m.GetType(), list);

            return(list);
        }
Exemple #3
0
        public int ScaleDamage(Mobile from, int damage)
        {
            if (from != null && (from.GetType() == m_Type || (m_Type != null && from.GetType().IsSubclassOf(m_Type))))
            {
                return((int)(damage * (1 - m_Amount / 100.0)));
            }

            return(damage);
        }
Exemple #4
0
 public override void Reset(Mobile m)
 {
     //Level = 1;
     Exp = TotalExp = 0;
     SetCap(999, 1000);
     if (CreatureLevel.StaticTable && Custom.StaticLevel.Table.ContainsKey(m.GetType()))
     {
         Level = Custom.StaticLevel.Table[m.GetType()];
     }
 }
Exemple #5
0
        /// <summary>
        /// Called in MondainQuester.cs
        /// </summary>
        /// <param name="player"></param>
        /// <param name="quester"></param>
        /// <returns></returns>
        public static bool InProgress(PlayerMobile player, Mobile quester)
        {
            BaseQuest quest = player.Quests.FirstOrDefault(q => q.QuesterType == quester.GetType());

            if (quest != null)
            {
                if (quest.Completed)
                {
                    if (quest.Complete == null && !AnyRewards(quest))
                    {
                        if (TryDeleteItems(quest))
                        {
                            quest.GiveRewards();
                        }
                    }
                    else
                    {
                        player.SendGump(new MondainQuestGump(quest, MondainQuestGump.Section.Complete, false, true));
                    }
                }
                else
                {
                    player.SendGump(new MondainQuestGump(quest, MondainQuestGump.Section.InProgress, false));
                    quest.InProgress();
                }

                return(true);
            }

            return(false);
        }
Exemple #6
0
        public void Target(Mobile m)
        {
            Type t           = m.GetType();
            bool dispellable = false;

            if (m is BaseCreature)
            {
                dispellable = ((BaseCreature)m).Summoned && !((BaseCreature)m).IsAnimatedDead;
            }

            if (!Caster.CanSee(m))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (!dispellable)
            {
                Caster.SendLocalizedMessage(1005049);                   // That cannot be dispelled.
            }
            else if (CheckHSequence(m))
            {
                SpellHelper.Turn(Caster, m);

                int diff;
                if (m is Daemon)
                {
                    diff = 95;
                }
                else if (m is EnergyVortex)
                {
                    diff = 80;
                }
                else if (m is FireElemental || m is WaterElemental || m is AirElemental || m is EarthElemental)
                {
                    diff = 75;
                }
                else if (m is BladeSpirit)
                {
                    diff = 50;
                }
                else
                {
                    diff = 0;
                }

                if (Caster.Skills[SkillName.Magery].Value >= Utility.Random(41) - 20 + diff)
                {
                    Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                    Effects.PlaySound(m, m.Map, 0x201);

                    m.Delete();
                }
                else
                {
                    m.Animate(14201, 10, 20, true, false, 0);
                    Caster.SendAsciiMessage("{0} resisted the attempt to dispell it!", m.Name);
                }
            }

            FinishSequence();
        }
        public Item Mutate(Mobile from, int luckChance, Item item)
        {
            if (item == null)
            {
                return(null);
            }

            if (item is BaseWeapon)
            {
                BaseWeapon weapon = (BaseWeapon)item;

                //Taran: Below we remove the items we don't want mobs to drop
                while (weapon is BaseKnife || weapon is Pickaxe || weapon is Hatchet || weapon is BaseStaff)
                {
                    weapon.Delete();
                    weapon = BaseWeapon.CreateRandomWeapon();
                }

                if (m_WeaponModifiers != null)
                {
                    m_WeaponModifiers.Mutate(weapon);
                }

                //if (5 > Utility.Random(100))
                //   weapon.Slayer = SlayerName.Silver;

                //if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 && weapon.Slayer == SlayerName.None && 5 > Utility.Random(100))
                //    weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType());

                weapon.Identified = true;
            }
            else if (item is BaseArmor)
            {
                BaseArmor armor = (BaseArmor)item;

                if (m_ArmorModifiers != null)
                {
                    m_ArmorModifiers.Mutate(armor);
                }

                armor.Identified = true;
            }
            else if (item is BaseInstrument)
            {
                SlayerName slayer = SlayerGroup.GetLootSlayerType(from.GetType());

                if (slayer == SlayerName.None)
                {
                    item.Delete();
                    return(null);
                }

                BaseInstrument instr = (BaseInstrument)item;

                instr.Quality = InstrumentQuality.Regular;
                instr.Slayer  = slayer;
            }

            return(item);
        }
Exemple #8
0
        public override void OnHit(Mobile attacker, Mobile defender, ref int damage)
        {
            if (!Validate(attacker))
            {
                return;
            }

            try
            {
                var spell = SpellRegistry.Create <DispelSpell>(attacker);

                spell.OnTargetAsync(new TargetResponse <Mobile>
                {
                    Target = defender,
                }).ConfigureAwait(false);

                if (SpellHelper.TryResist(attacker, defender, spell.Circle))
                {
                    defender.Mana = 0;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(
                    $"Failed to invoke {GetType().Name} for Mobile: {attacker.GetType().Name}, Serial: {attacker.Serial}");
            }
        }
        private static bool MatchType(ArrayList array, Mobile m)
        {
            if (array == null || m == null)
            {
                return(false);
            }

            foreach (object o in array)
            {
                if (o is Type && ((Type)o == m.GetType() || ((Type)o).IsSubclassOf(m.GetType())))
                {
                    return(true);
                }
            }
            return(false);
        }
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (!m_Table.ContainsKey(name))
            {
                return(false);
            }

            Type[] types = m_Table[name];

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

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                {
                    return(true);
                }
            }

            return(false);
        }
        public override void Execute(CommandEventArgs e, object obj)
        {
            Mobile m    = obj as Mobile;
            Mobile from = e.Mobile;

            if (m != null)
            {
                List <AggressorInfo> aggressors = m.Aggressors;
                if (aggressors.Count > 0)
                {
                    for (int i = 0; i < aggressors.Count; ++i)
                    {
                        AggressorInfo info = (AggressorInfo)aggressors[i];
                        Mobile        temp = info.Attacker;
                        from.SendMessage("Aggressor:{0} '{1}' Ser:{2}, Time:{3}, Expired:{4}",
                                         (temp is PlayerMobile ? ((PlayerMobile)temp).Account.ToString() : ((Mobile)temp).Name),
                                         temp.GetType().Name,
                                         temp.Serial,
                                         info.LastCombatTime.TimeOfDay,
                                         info.Expired);
                    }
                }
            }
            else
            {
                AddResponse("Please target a mobile.");
            }
        }
        public static string GetCorpseName(Mobile m)
        {
            Type t = m.GetType();

            object[] attrs = t.GetCustomAttributes(typeof(CorpseNameAttribute), true);

            if (attrs != null && attrs.Length > 0)
            {
                CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;

                if (attr != null)
                {
                    if (m is BaseCreature)
                    {
                        // Does it have a spawner?
                        if (((BaseCreature)m).Spawner != null)
                        {
                            // Do we have a custom name we need to use?
                            Spawner sp = ((BaseCreature)m).Spawner;

                            if (sp.TemplateEnabled && sp.TemplateMobile != null)
                            {
                                // Let the system catch and handle this
                                return(null);
                            }
                        }
                    }
                    return(attr.Name);
                }
            }

            return(null);
        }
Exemple #13
0
        public static string GetCorpseName(Mobile m)
        {
            Type t = m.GetType();

            PlayerMobile tmob = m as PlayerMobile;

            if (tmob != null && tmob.Race != null)
            {
                if (tmob.Female)
                {
                    return(tmob.Race.NameF);
                }
                else
                {
                    return(tmob.Race.Name);
                }
            }


            object[] attrs = t.GetCustomAttributes(typeof(CorpseNameAttribute), true);

            if (attrs != null && attrs.Length > 0)
            {
                CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;

                if (attr != null)
                {
                    return(attr.Name);
                }
            }

            return(null);
        }
Exemple #14
0
        private static void CopyMobileProps(Mobile dest, Mobile src, params string[] omitProps)
        {
            Type type = src.GetType();

            PropertyInfo[] props = type.GetProperties();

            for (int i = 0; i < props.Length; i++)
            {
                try
                {
                    bool omit = false;
                    for (int j = 0; j < omitProps.Length; j++)
                    {
                        if (string.Compare(omitProps[j], props[i].Name, true) == 0)
                        {
                            omit = true;
                            break;
                        }
                    }

                    if (props[i].CanRead && props[i].CanWrite && !omit)
                    {
                        props[i].SetValue(dest, props[i].GetValue(src, null), null);
                    }
                }
                catch
                {
                    //Console.WriteLine( "Denied" );
                }
            }
        }
Exemple #15
0
        private static bool MatchType(List <Type> list, Mobile m)
        {
            if (list == null || m == null)
            {
                return(false);
            }

            foreach (Type o in list)
            {
                if (o == m.GetType() || o.IsSubclassOf(m.GetType()))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #16
0
        public void OnHit(Mobile defender)
        {
            if (m_TargetType == null)
            {
                m_TypeName = EnemyOfOneSpell.GetTypeName(defender);

                if (defender is PlayerMobile || (defender is BaseCreature bc && bc.GetMaster() is PlayerMobile))
                {
                    m_PlayerOrPet = defender;
                    TimeSpan duration = TimeSpan.FromSeconds(8);

                    if (DateTime.UtcNow + duration < m_Expire)
                    {
                        m_Expire = DateTime.UtcNow + duration;
                    }

                    if (m_Timer != null)
                    {
                        m_Timer.Stop();
                        m_Timer = null;
                    }

                    m_Timer = Timer.DelayCall(duration, EnemyOfOneSpell.RemoveEffect, m_Owner);
                }
                else
                {
                    m_TargetType = defender.GetType();
                }

                UpdateDamage();
                DeltaEnemies();
                UpdateBuffInfo();
            }
Exemple #17
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (name == TalismanSlayerName.None)
            {
                return(false);
            }

            Type[] types = m_Table[name];

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

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i] == type)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #18
0
        // note that this method will be called when attached to either a mobile or a weapon
        // when attached to a weapon, only that weapon will do additional damage
        // when attached to a mobile, any weapon the mobile wields will do additional damage
        public override void OnWeaponHit(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven)
        {
            if (m_Chance <= 0 || Utility.Random(100) > m_Chance)
            {
                return;
            }

            if (defender != null && attacker != null && m_EnemyType != null)
            {
                // is the defender the correct type?
                if (defender.GetType() == m_EnemyType || defender.GetType().IsSubclassOf(m_EnemyType))
                {
                    defender.Damage((damageGiven * PercentIncrease / 100), attacker);
                }
            }
        }
Exemple #19
0
        public static bool OnProvoked(PlayerMobile player, Mobile source, Mobile target)
        {
            for (int i = player.Quests.Count - 1; i >= 0; i--)
            {
                BaseQuest quest = player.Quests[i];

                for (int j = quest.Objectives.Count - 1; j >= 0; j--)
                {
                    if (quest.Objectives[j] is InciteObjective)
                    {
                        InciteObjective obj = (InciteObjective)quest.Objectives[j];

                        if (obj.SourceTypes.Any(t => t.IsAssignableFrom(source.GetType())))
                        {
                            if (obj.Update(target))
                            {
                                if (quest.Completed)
                                {
                                    quest.OnCompleted();
                                }
                                if (obj.Completed)
                                {
                                    player.PlaySound(quest.UpdateSound);
                                }

                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Exemple #20
0
        public void PossessMobile(Mobile target)
        {
            if (possessed != null)
            {
                mobile.SendMessage("Vous posseder deja une creature");
                return;
            }

            stored = (Mobile)Activator.CreateInstance(mobile.GetType());

            possessed = target;

            CopySkills(mobile, stored);
            CopyProps(mobile, stored);
            MoveItems(mobile, stored);

            mobile.Location  = possessed.Location;
            mobile.Direction = possessed.Direction;
            mobile.Map       = possessed.Map;

            CopySkills(possessed, mobile);
            CopyProps(possessed, mobile);
            CopyItems(possessed, mobile);

            mobile.Hits = mobile.HitsMax;

            possessed.Frozen = true;
            possessed.Map    = Map.Internal;

            mobile.Frozen   = false;
            mobile.CantWalk = false;
        }
Exemple #21
0
        public static void CopyProps(Mobile from, Mobile to)
        {
            try
            {
                PropertyInfo[] props = from.GetType().GetProperties();

                for (int i = 0; i < props.Length; i++)
                {
                    try
                    {
                        if (ToChange(props[i].Name))
                        {
                            if (props[i].CanRead && props[i].CanWrite)
                            {
                                props[i].SetValue(to, props[i].GetValue(from, null), null);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Possess: CopyProps (Mobile) Exception: {0}", e.Message);
                Misc.ExceptionLogging.WriteLine(e);
            }
        }
		public void Target( Mobile m )
		{
			Type t = m.GetType();
			bool dispellable = false;

			if ( m is BaseCreature )
				dispellable = ((BaseCreature)m).Summoned;

			if ( !Caster.CanSee( m ) )
			{
				Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
			}
			else if ( !dispellable )
			{
				Caster.SendLocalizedMessage( 1005049 ); // That cannot be dispelled.
			}
			else if ( CheckHSequence( m ) )
			{
				SpellHelper.Turn( Caster, m );

				if ( CheckResisted( m ) )
				{
					m.FixedEffect( 0x3779, 10, 20 );
				}
				else
				{
					Effects.SendLocationParticles( EffectItem.Create( m.Location, m.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
					Effects.PlaySound( m, m.Map, 0x201 );

					m.Delete();
				}
			}

			FinishSequence();
		}
Exemple #23
0
        public static string GetCorpseName(Mobile m)
        {
            XmlData x = (XmlData)XmlAttach.FindAttachment(m, typeof(XmlData), "CorpseName");

            if (x != null)
            {
                return(x.Data);
            }

            if (m is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)m;

                if (bc.CorpseNameOverride != null)
                {
                    return(bc.CorpseNameOverride);
                }
            }

            Type t = m.GetType();

            var attrs = t.GetCustomAttributes(typeof(CorpseNameAttribute), true);

            if (attrs != null && attrs.Length > 0)
            {
                CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;

                if (attr != null)
                {
                    return(attr.Name);
                }
            }

            return(null);
        }
Exemple #24
0
        public bool Slays(Mobile m)
        {
            if (m.SpecialSlayerMechanics)
            {
                if (m.SlayerVulnerabilities.Contains(m_Name.ToString()))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            Type t = m.GetType();

            for (int i = 0; i < this.m_Types.Length; ++i)
            {
                if (this.m_Types[i].IsAssignableFrom(t))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #25
0
        public static string GetCorpseName(Mobile m)
        {
            if (m is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)m;

                if (bc.CorpseNameOverride != null)
                {
                    return(bc.CorpseNameOverride);
                }
            }

            Type t = m.GetType();

            object[] attrs = t.GetCustomAttributes(typeof(CorpseNameAttribute), true);

            if (attrs.Length > 0)
            {
                CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;

                if (attr != null)
                {
                    return(attr.Name);
                }
            }

            return(null);
        }
Exemple #26
0
        public int DamageBonus(Mobile to)
        {
            if (to != null && to.GetType() == m_Type)               // Verified: only works on the exact type
            {
                return(m_Amount);
            }

            return(0);
        }
Exemple #27
0
        private void btnMobile_Click(object sender, EventArgs e)
        {
            Mobile phone = new Mobile();

            phone.Brand          = "Nokia";
            phone.ConnectionType = "4G Mobile";

            MessageBox.Show($"Telefonun Türü\t\t : {phone.GetType().Name}\nTelefonun Markası\t\t : {phone.Brand}\nTelefonun Bağlantı Türü\t : {phone.ConnectionType}\nTelefonun sesi\t\t : {phone.Sound()}\nTelefonun Kamerası\t : {(phone.HasCamera?"Var":"Yok")}");
        }
Exemple #28
0
        public bool IsEvolutionType(Mobile from)
        {
            if (Stage == 0 && from.GetType() != GetType())
            {
                return(false);
            }

            return(from is BaseVoidCreature);
        }
Exemple #29
0
        /// <summary>
        /// Called in MondainQuester.cs
        /// </summary>
        /// <param name="player"></param>
        /// <param name="quester"></param>
        /// <returns></returns>
        public static bool InProgress(PlayerMobile player, Mobile quester)
        {
            BaseQuest quest = player.Quests.FirstOrDefault(q => q.QuesterType == quester.GetType());

            if (quest != null)
            {
                if (quest.Completed)
                {
                    if (quest.Complete == null && !AnyRewards(quest))
                    {
                        if (TryDeleteItems(quest))
                        {
                            quest.GiveRewards();
                        }
                    }
                    else
                    {
                        player.SendGump(new MondainQuestGump(quest, MondainQuestGump.Section.Complete, false, true));
                    }
                }
                else
                {
                    player.SendGump(new MondainQuestGump(quest, MondainQuestGump.Section.InProgress, false));
                    quest.InProgress();
                }

                return(true);
            }

            /*for (int i = 0; i < player.Quests.Count; i ++)
             * {
             *  BaseQuest quest = player.Quests[i];
             *
             *  if (quest.Quester == null && quest.QuesterType == null)
             *      continue;
             *
             *  if (quest.QuesterType == quester.GetType())
             *  {
             *      if (quest.Completed)
             *      {
             *          if (quest.Complete == null && !AnyRewards(quest))
             *              quest.GiveRewards();
             *          else
             *              player.SendGump(new MondainQuestGump(quest, MondainQuestGump.Section.Complete, false, true));
             *      }
             *      else
             *      {
             *          player.SendGump(new MondainQuestGump(quest, MondainQuestGump.Section.InProgress, false));
             *          quest.InProgress();
             *      }
             *
             *      return true;
             *  }
             * }*/

            return(false);
        }
        public int DamageBonus(Mobile to)
        {
            if (to != null && to.GetType() == m_Type)
            {
                return(m_Amount);
            }

            return(0);
        }
Exemple #31
0
        public static string GetTypeName(Mobile defender)
        {
            Type t = defender.GetType();

            if (NameCache.ContainsKey(t))
            {
                return(NameCache[t]);
            }

            return(AddNameToCache(t));
        }
Exemple #32
0
        public void Target( Mobile m )
        {
            Type t = m.GetType();
            bool dispellable = false;

            if ( m is BaseCreature )
                dispellable = ((BaseCreature)m).Summoned && !((BaseCreature)m).IsAnimatedDead;

            if ( !Caster.CanSee( m ) )
            {
                Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
            }
            else if ( !dispellable )
            {
                Caster.SendLocalizedMessage( 1005049 ); // That cannot be dispelled.
            }
            else if ( CheckHSequence( m ) )
            {
                SpellHelper.Turn( Caster, m );

                int diff;
                if ( m is Daemon )
                    diff = 95;
                else if ( m is EnergyVortex )
                    diff = 80;
                else if ( m is FireElemental || m is WaterElemental || m is AirElemental || m is EarthElemental )
                    diff = 75;
                else if ( m is BladeSpirit )
                    diff = 50;
                else
                    diff = 0;

                if ( Caster.Skills[SkillName.Magery].Value >= Utility.Random( 41 )-20+diff )
                {
                    Effects.SendLocationParticles( EffectItem.Create( m.Location, m.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
                    Effects.PlaySound( m, m.Map, 0x201 );

                    m.Delete();
                }
                else
                {
                    m.Animate( 14201, 10, 20, true, false, 0 );
                    Caster.SendAsciiMessage( "{0} resisted the attempt to dispell it!", m.Name );
                }
            }

            FinishSequence();
        }
Exemple #33
0
        public void Target( Mobile m )
        {
            Type t = m.GetType();
            bool dispellable = false;

            if ( m is BaseCreature )
                dispellable = ((BaseCreature)m).Summoned && !((BaseCreature)m).IsAnimatedDead;

            if ( !Caster.CanSee( m ) )
            {
                Caster.SendAsciiMessage( "Target can not be seen." );
            }
            else if ( !dispellable )
            {
                Caster.SendAsciiMessage( "That cannot be dispelled." );
            }
            else if ( CheckHSequence( m ) )
            {
                SpellHelper.Turn( Caster, m );

                BaseCreature bc = m as BaseCreature;

                double dispelChance = 0;

                if ( bc != null )
                    dispelChance = (50.0 + ((100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty)) / (bc.DispelFocus*2))) / 100;

                if ( dispelChance > Utility.RandomDouble() )
                {
                    Effects.SendLocationParticles( EffectItem.Create( m.Location, m.Map, EffectItem.DefaultDuration ), 0x3728, 8, 20, 5042 );
                    Effects.PlaySound( m, m.Map, 0x201 );

                    m.Delete();
                }
                else
                {
                    m.FixedEffect( 0x3779, 10, 20 );
                    Caster.SendAsciiMessage( "The creature resisted the attempt to dispel it!" );
                }
            }

            FinishSequence();
        }
Exemple #34
0
        public override void OnKill(Mobile killed, Mobile killer)
        {
            base.OnKill(killed, killer);

            // supports ignoring XmlPoints challenges
            if (this.m_ChallengeStatus)
            {
                this.m_ChallengeStatus = false;
                return;
            }

            if (killed == null || killer == null || killer == killed)
                return;
		    
            // check for within guild kills and ignore them
            if (this.SameGuild(killed, killer))
                return;

            // this calculates the base faction level that will be gained/lost based upon the fame of the killed mob
            double value = (double)(killed.Fame / 1000.0);
            if (value <= 0)
                value = 1;

            // calculates credits gained in a similar way
            int cval = (int)(killed.Fame * m_CreditScale);
            if (cval <= 0)
                cval = 1;

            this.Credits += cval;

            // prepare the group lists that will be checked for faction
            ArrayList glist = null;
            ArrayList dglist = null;

            // check to see whether this mob type has already been hashed into a group list
            if (GroupHash.Contains(killed.GetType()))
            {
                glist = (ArrayList)GroupHash[killed.GetType()];
            }
            else
            {
                // otherwise look it up the slow way and prepare a hash entry for it at the same time
                // unless it is using dynamic faction
                glist = new ArrayList();
                foreach (Group g in KillGroups)
                {
                    if (MatchType(g.Members, killed))
                    {
                        glist.Add(g);
                    }
                }
                GroupHash.Add(killed.GetType(), glist);
            }

            // have to look up dynamic factions the exhaustive way
            // does this mob have dynamic faction assignments?
            ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, killed, typeof(XmlDynamicFaction));
            if (list != null && list.Count > 0)
            {
                //if(XmlAttach.FindAttachment(XmlAttach.MobileAttachments, killed, typeof(XmlDynamicFaction)) != null)
                //{
                dglist = new ArrayList();
                foreach (Group g in KillGroups)
                {
                    if (DynamicMatchType(g.Members, killed))
                    {
                        dglist.Add(g);
                    }
                }
            }

            ArrayList alist = new ArrayList();
            if (glist != null && glist.Count > 0)
                alist.Add(glist);
            if (dglist != null && dglist.Count > 0)
                alist.Add(dglist);

            //  go through this with static and dynamic factions
            foreach (ArrayList al in alist)
            {
                foreach (Group g in al)
                {
                    // tabulate the faction loss from target group allies
                    if (g.Allies != null && g.Allies.Length > 0)
                    {
                        for (int i = 0; i < g.Allies.Length; i++)
                        {
                            Group ally = g.Allies[i];

                            int facloss = 0;
                            try
                            {
                                facloss = (int)(value * g.AllyLoss[i]);
                            }
                            catch
                            {
                            }
                            if (facloss <= 0)
                                facloss = 1;
        
                            int p = this.GetFactionLevel(ally.GroupType) - facloss;
                            this.SetFactionLevel(ally.GroupType, p);
                            if (this.verboseMobFactions)
                                killer.SendMessage("lost {0} faction {1}", ally.GroupType, facloss);
                        }
                    }

                    // tabulate the faction gain from target group opponents
                    if (g.Opponents != null && g.Opponents.Length > 0)
                    {
                        for (int i = 0; i < g.Opponents.Length; i++)
                        {
                            Group opp = g.Opponents[i];

                            int facgain = 0;
                            try
                            {
                                facgain = (int)(value * g.OpponentGain[i]);
                            }
                            catch
                            {
                            }
                            if (facgain <= 0)
                                facgain = 1;

                            int p = this.GetFactionLevel(opp.GroupType) + facgain;
                            this.SetFactionLevel(opp.GroupType, p);
                            if (this.verboseMobFactions)
                                killer.SendMessage("gained {0} faction {1}", opp.GroupType, facgain);
                        }
                    }
                }
            }

            this.m_EndTime = DateTime.UtcNow + this.Refractory;
        }
Exemple #35
0
        // this method returns a list of the group types that the mobile belongs to using the KillGroups master list
        public static ArrayList FindGroups(Mobile m)
        {
            if (m == null)
                return null;

            // see whether this mobile type is already in the hash table
            if (GroupTypeHash.Contains(m.GetType()))
            {
                // then get the list from there
                return (ArrayList)GroupTypeHash[m.GetType()];
            }

            ArrayList list = new ArrayList();

            foreach (Group g in KillGroups)
            {
                if (MatchType(g.Members, m))
                {
                    list.Add(g.GroupType);
                }
            }
            GroupTypeHash.Add(m.GetType(), list);

            return list;
        }
Exemple #36
0
        private static bool MatchType(ArrayList array, Mobile m)
        {
            if (array == null || m == null)
                return false;

            foreach (object o in array)
            {
                if (o is Type && ((Type)o == m.GetType() || ((Type)o).IsSubclassOf(m.GetType())))
                    return true;
            }
            return false;
        }
Exemple #37
0
        public virtual void OnHit( Mobile attacker, Mobile defender, double damageBonus )
        {
            if ( MirrorImage.HasClone( defender ) && (defender.Skills.Ninjitsu.Value / 150.0) > Utility.RandomDouble() )
            {
                Clone bc;

                foreach ( Mobile m in defender.GetMobilesInRange( 4 ) )
                {
                    bc = m as Clone;

                    if ( bc != null && bc.Summoned && bc.SummonMaster == defender )
                    {
                        attacker.SendLocalizedMessage( 1063141 ); // Your attack has been diverted to a nearby mirror image of your target!
                        defender.SendLocalizedMessage( 1063140 ); // You manage to divert the attack onto one of your nearby mirror images.

                        /*
                         * TODO: What happens if the Clone parries a blow?
                         * And what about if the attacker is using Honorable Execution
                         * and kills it?
                         */

                        defender = m;
                        break;
                    }
                }
            }

            PlaySwingAnimation( attacker );
            PlayHurtAnimation( defender );

            attacker.PlaySound( GetHitAttackSound( attacker, defender ) );
            defender.PlaySound( GetHitDefendSound( attacker, defender ) );

            int damage = ComputeDamage( attacker, defender );

            #region Damage Multipliers
            /*
             * The following damage bonuses multiply damage by a factor.
             * Capped at x3 (300%).
             */
            //double factor = 1.0;
            int percentageBonus = 0;

            WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );
            SpecialMove move = SpecialMove.GetCurrentMove( attacker );

            if( a != null )
            {
                //factor *= a.DamageScalar;
                percentageBonus += (int)(a.DamageScalar * 100) - 100;
            }

            if( move != null )
            {
                //factor *= move.GetDamageScalar( attacker, defender );
                percentageBonus += (int)(move.GetDamageScalar( attacker, defender ) * 100) - 100;
            }

            //factor *= damageBonus;
            percentageBonus += (int)(damageBonus * 100) - 100;

            CheckSlayerResult cs = CheckSlayers( attacker, defender );

            if ( cs != CheckSlayerResult.None )
            {
                if ( cs == CheckSlayerResult.Slayer )
                    defender.FixedEffect( 0x37B9, 10, 5 );

                //factor *= 2.0;
                percentageBonus += 100;
            }

            if ( !attacker.Player )
            {
                if ( defender is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)defender;

                    if( pm.EnemyOfOneType != null && pm.EnemyOfOneType != attacker.GetType() )
                    {
                        //factor *= 2.0;
                        percentageBonus += 100;
                    }
                }
            }
            else if ( !defender.Player )
            {
                if ( attacker is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)attacker;

                    if ( pm.WaitingForEnemy )
                    {
                        pm.EnemyOfOneType = defender.GetType();
                        pm.WaitingForEnemy = false;
                    }

                    if ( pm.EnemyOfOneType == defender.GetType() )
                    {
                        defender.FixedEffect( 0x37B9, 10, 5, 1160, 0 );
                        //factor *= 1.5;
                        percentageBonus += 50;
                    }
                }
            }

            int packInstinctBonus = GetPackInstinctBonus( attacker, defender );

            if( packInstinctBonus != 0 )
            {
                //factor *= 1.0 + (double)packInstinctBonus / 100.0;
                percentageBonus += packInstinctBonus;
            }

            if( m_InDoubleStrike )
            {
                //factor *= 0.9; // 10% loss when attacking with double-strike
                percentageBonus -= 10;
            }

            TransformContext context = TransformationSpellHelper.GetContext( defender );

            if( (m_Slayer == SlayerName.Silver || m_Slayer2 == SlayerName.Silver) && context != null && context.Spell is NecromancerSpell && context.Type != typeof( HorrificBeastSpell ) )
            {
                //factor *= 1.25; // Every necromancer transformation other than horrific beast takes an additional 25% damage
                percentageBonus += 25;
            }

            if ( attacker is PlayerMobile && !(Core.ML && defender is PlayerMobile ))
            {
                PlayerMobile pmAttacker = (PlayerMobile) attacker;

                if( pmAttacker.HonorActive && pmAttacker.InRange( defender, 1 ) )
                {
                    //factor *= 1.25;
                    percentageBonus += 25;
                }

                if( pmAttacker.SentHonorContext != null && pmAttacker.SentHonorContext.Target == defender )
                {
                    //pmAttacker.SentHonorContext.ApplyPerfectionDamageBonus( ref factor );
                    percentageBonus += pmAttacker.SentHonorContext.PerfectionDamageBonus;
                }
            }

            //if ( factor > 3.0 )
            //	factor = 3.0;

            percentageBonus = Math.Min( percentageBonus, 300 );

            //damage = (int)(damage * factor);
            damage = AOS.Scale( damage, 100 + percentageBonus );
            #endregion

            if ( attacker is BaseCreature )
                ((BaseCreature)attacker).AlterMeleeDamageTo( defender, ref damage );

            if ( defender is BaseCreature )
                ((BaseCreature)defender).AlterMeleeDamageFrom( attacker, ref damage );

            damage = AbsorbDamage( attacker, defender, damage );

            if ( !Core.AOS && damage < 1 )
                damage = 1;
            else if ( Core.AOS && damage == 0 ) // parried
            {
                if ( a != null && a.Validate( attacker ) /*&& a.CheckMana( attacker, true )*/ ) // Parried special moves have no mana cost
                {
                    a = null;
                    WeaponAbility.ClearCurrentAbility( attacker );

                    attacker.SendLocalizedMessage( 1061140 ); // Your attack was parried!
                }
            }

            AddBlood( attacker, defender, damage );

            int phys, fire, cold, pois, nrgy, chaos, direct;

            GetDamageTypes( attacker, out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct );

            if ( Core.ML && this is BaseRanged )
            {
                BaseQuiver quiver = attacker.FindItemOnLayer( Layer.Cloak ) as BaseQuiver;

                if ( quiver != null )
                    quiver.AlterBowDamage( ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct );
            }

            if ( m_Consecrated )
            {
                phys = defender.PhysicalResistance;
                fire = defender.FireResistance;
                cold = defender.ColdResistance;
                pois = defender.PoisonResistance;
                nrgy = defender.EnergyResistance;

                int low = phys, type = 0;

                if ( fire < low ){ low = fire; type = 1; }
                if ( cold < low ){ low = cold; type = 2; }
                if ( pois < low ){ low = pois; type = 3; }
                if ( nrgy < low ){ low = nrgy; type = 4; }

                phys = fire = cold = pois = nrgy = chaos = direct = 0;

                if ( type == 0 ) phys = 100;
                else if ( type == 1 ) fire = 100;
                else if ( type == 2 ) cold = 100;
                else if ( type == 3 ) pois = 100;
                else if ( type == 4 ) nrgy = 100;
            }

            int damageGiven = damage;

            if ( a != null && !a.OnBeforeDamage( attacker, defender ) )
            {
                WeaponAbility.ClearCurrentAbility( attacker );
                a = null;
            }

            if ( move != null && !move.OnBeforeDamage( attacker, defender ) )
            {
                SpecialMove.ClearCurrentMove( attacker );
                move = null;
            }

            bool ignoreArmor = ( a is ArmorIgnore || (move != null && move.IgnoreArmor( attacker )) );

            damageGiven = AOS.Damage( defender, attacker, damage, ignoreArmor, phys, fire, cold, pois, nrgy, chaos, direct, false, this is BaseRanged );

            double propertyBonus = ( move == null ) ? 1.0 : move.GetPropertyBonus( attacker );

            if ( Core.AOS )
            {
                int lifeLeech = 0;
                int stamLeech = 0;
                int manaLeech = 0;
                int wraithLeech = 0;

                if ( (int)(m_AosWeaponAttributes.HitLeechHits * propertyBonus) > Utility.Random( 100 ) )
                    lifeLeech += 30; // HitLeechHits% chance to leech 30% of damage as hit points

                if ( (int)(m_AosWeaponAttributes.HitLeechStam * propertyBonus) > Utility.Random( 100 ) )
                    stamLeech += 100; // HitLeechStam% chance to leech 100% of damage as stamina

                if ( (int)(m_AosWeaponAttributes.HitLeechMana * propertyBonus) > Utility.Random( 100 ) )
                    manaLeech += 40; // HitLeechMana% chance to leech 40% of damage as mana

                if ( m_Cursed )
                    lifeLeech += 50; // Additional 50% life leech for cursed weapons (necro spell)

                context = TransformationSpellHelper.GetContext( attacker );

                if ( context != null && context.Type == typeof( VampiricEmbraceSpell ) )
                    lifeLeech += 20; // Vampiric embrace gives an additional 20% life leech

                if ( context != null && context.Type == typeof( WraithFormSpell ) )
                {
                    wraithLeech = (5 + (int)((15 * attacker.Skills.SpiritSpeak.Value) / 100)); // Wraith form gives an additional 5-20% mana leech

                    // Mana leeched by the Wraith Form spell is actually stolen, not just leeched.
                    defender.Mana -= AOS.Scale( damageGiven, wraithLeech );

                    manaLeech += wraithLeech;
                }

                if ( lifeLeech != 0 )
                    attacker.Hits += AOS.Scale( damageGiven, lifeLeech );

                if ( stamLeech != 0 )
                    attacker.Stam += AOS.Scale( damageGiven, stamLeech );

                if ( manaLeech != 0 )
                    attacker.Mana += AOS.Scale( damageGiven, manaLeech );

                if ( lifeLeech != 0 || stamLeech != 0 || manaLeech != 0 )
                    attacker.PlaySound( 0x44D );
            }

            if ( m_MaxHits > 0 && ((MaxRange <= 1 && (defender is Slime || defender is ToxicElemental)) || Utility.Random( 25 ) == 0) ) // Stratics says 50% chance, seems more like 4%..
            {
                if ( MaxRange <= 1 && (defender is Slime || defender is ToxicElemental) )
                    attacker.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500263 ); // *Acid blood scars your weapon!*

                if ( Core.AOS && m_AosWeaponAttributes.SelfRepair > Utility.Random( 10 ) )
                {
                    HitPoints += 2;
                }
                else
                {
                    if ( m_Hits > 0 )
                    {
                        --HitPoints;
                    }
                    else if ( m_MaxHits > 1 )
                    {
                        --MaxHitPoints;

                        if ( Parent is Mobile )
                            ((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
                    }
                    else
                    {
                        Delete();
                    }
                }
            }

            if ( attacker is VampireBatFamiliar )
            {
                BaseCreature bc = (BaseCreature)attacker;
                Mobile caster = bc.ControlMaster;

                if ( caster == null )
                    caster = bc.SummonMaster;

                if ( caster != null && caster.Map == bc.Map && caster.InRange( bc, 2 ) )
                    caster.Hits += damage;
                else
                    bc.Hits += damage;
            }

            if ( Core.AOS )
            {
                int physChance = (int)(m_AosWeaponAttributes.HitPhysicalArea * propertyBonus);
                int fireChance = (int)(m_AosWeaponAttributes.HitFireArea * propertyBonus);
                int coldChance = (int)(m_AosWeaponAttributes.HitColdArea * propertyBonus);
                int poisChance = (int)(m_AosWeaponAttributes.HitPoisonArea * propertyBonus);
                int nrgyChance = (int)(m_AosWeaponAttributes.HitEnergyArea * propertyBonus);

                if ( physChance != 0 && physChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x10E,   50, 100, 0, 0, 0, 0 );

                if ( fireChance != 0 && fireChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x11D, 1160, 0, 100, 0, 0, 0 );

                if ( coldChance != 0 && coldChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x0FC, 2100, 0, 0, 100, 0, 0 );

                if ( poisChance != 0 && poisChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x205, 1166, 0, 0, 0, 100, 0 );

                if ( nrgyChance != 0 && nrgyChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x1F1,  120, 0, 0, 0, 0, 100 );

                int maChance = (int)(m_AosWeaponAttributes.HitMagicArrow * propertyBonus);
                int harmChance = (int)(m_AosWeaponAttributes.HitHarm * propertyBonus);
                int fireballChance = (int)(m_AosWeaponAttributes.HitFireball * propertyBonus);
                int lightningChance = (int)(m_AosWeaponAttributes.HitLightning * propertyBonus);
                int dispelChance = (int)(m_AosWeaponAttributes.HitDispel * propertyBonus);

                if ( maChance != 0 && maChance > Utility.Random( 100 ) )
                    DoMagicArrow( attacker, defender );

                if ( harmChance != 0 && harmChance > Utility.Random( 100 ) )
                    DoHarm( attacker, defender );

                if ( fireballChance != 0 && fireballChance > Utility.Random( 100 ) )
                    DoFireball( attacker, defender );

                if ( lightningChance != 0 && lightningChance > Utility.Random( 100 ) )
                    DoLightning( attacker, defender );

                if ( dispelChance != 0 && dispelChance > Utility.Random( 100 ) )
                    DoDispel( attacker, defender );

                int laChance = (int)(m_AosWeaponAttributes.HitLowerAttack * propertyBonus);
                int ldChance = (int)(m_AosWeaponAttributes.HitLowerDefend * propertyBonus);

                if ( laChance != 0 && laChance > Utility.Random( 100 ) )
                    DoLowerAttack( attacker, defender );

                if ( ldChance != 0 && ldChance > Utility.Random( 100 ) )
                    DoLowerDefense( attacker, defender );
            }

            if ( attacker is BaseCreature )
                ((BaseCreature)attacker).OnGaveMeleeAttack( defender );

            if ( defender is BaseCreature )
                ((BaseCreature)defender).OnGotMeleeAttack( attacker );

            if ( a != null )
                a.OnHit( attacker, defender, damage );

            if ( move != null )
                move.OnHit( attacker, defender, damage );

            if ( defender is IHonorTarget && ((IHonorTarget)defender).ReceivedHonorContext != null )
                ((IHonorTarget)defender).ReceivedHonorContext.OnTargetHit( attacker );

            if ( !(this is BaseRanged) )
            {
                if ( AnimalForm.UnderTransformation( attacker, typeof( GiantSerpent ) ) )
                    defender.ApplyPoison( attacker, Poison.Lesser );

                if ( AnimalForm.UnderTransformation( defender, typeof( BullFrog ) ) )
                    attacker.ApplyPoison( defender, Poison.Regular );
            }
        }
Exemple #38
0
        public bool Slays(Mobile m)
        {
            Type t = m.GetType();

            for (int i = 0; i < this.m_Types.Length; ++i)
            {
                if (this.m_Types[i].IsAssignableFrom(t))
                    return true;
            }

            return false;
        }
Exemple #39
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {

            if (m.SpecialSlayerMechanics)
            {
                if (m.SlayerVulnerabilities.Contains(name.ToString()))
                    return true;
                else
                    return false;
                
            }

            if (!m_Table.ContainsKey(name))
                return false;

            Type[] types = m_Table[name];
			
            if (types == null || m == null)
                return false;

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                    return true;
            }

            return false;
        }
Exemple #40
0
        public virtual void OnHit( Mobile attacker, Mobile defender )
        {
            PlaySwingAnimation( attacker );
            PlayHurtAnimation( defender );

            attacker.PlaySound( GetHitAttackSound( attacker, defender ) );
            defender.PlaySound( GetHitDefendSound( attacker, defender ) );

            int damage = ComputeDamage( attacker, defender );

            CheckSlayerResult cs = CheckSlayers( attacker, defender );

            if ( cs != CheckSlayerResult.None )
            {
                if ( cs == CheckSlayerResult.Slayer )
                    defender.FixedEffect( 0x37B9, 10, 5 );

                damage *= 2;
            }

            if ( !attacker.Player )
            {
                if ( defender is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)defender;

                    if ( pm.EnemyOfOneType != null && pm.EnemyOfOneType != attacker.GetType() )
                        damage *= 2;
                }
            }
            else if ( !defender.Player )
            {
                if ( attacker is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)attacker;

                    if ( pm.WaitingForEnemy )
                    {
                        pm.EnemyOfOneType = defender.GetType();
                        pm.WaitingForEnemy = false;
                    }

                    if ( pm.EnemyOfOneType == defender.GetType() )
                    {
                        defender.FixedEffect( 0x37B9, 10, 5, 1160, 0 );
                        damage += AOS.Scale( damage, 50 );
                    }
                }
            }

            int packInstinctBonus = GetPackInstinctBonus( attacker, defender );

            if ( packInstinctBonus != 0 )
                damage += AOS.Scale( damage, packInstinctBonus );

            if ( m_InDoubleStrike )
                damage -= AOS.Scale( damage, 10 ); // 10% loss when attacking with double-strike

            TransformContext context = TransformationSpell.GetContext( defender );

            if ( m_Slayer == SlayerName.Silver && context != null && context.Type != typeof( HorrificBeastSpell ) )
                damage += AOS.Scale( damage, 25 ); // Every necromancer transformation other than horrific beast take an additional 25% damage

            if ( attacker is BaseCreature )
                ((BaseCreature)attacker).AlterMeleeDamageTo( defender, ref damage );

            if ( defender is BaseCreature )
                ((BaseCreature)defender).AlterMeleeDamageFrom( attacker, ref damage );

            WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );

            damage = AbsorbDamage( attacker, defender, damage );

            if ( !Core.AOS && damage < 1 )
                damage = 1;
            else if ( Core.AOS && damage == 0 ) // parried
            {
                if ( a != null && a.Validate( attacker ) /*&& a.CheckMana( attacker, true )*/ ) // Parried special moves have no mana cost
                {
                    a = null;
                    WeaponAbility.ClearCurrentAbility( attacker );

                    attacker.SendAsciiMessage( "Your attack was parried!" );
                }
            }

            AddBlood( attacker, defender, damage );

            int phys, fire, cold, pois, nrgy;

            GetDamageTypes( attacker, out phys, out fire, out cold, out pois, out nrgy );

            if ( m_Consecrated )
            {
                phys = defender.PhysicalResistance;
                fire = defender.FireResistance;
                cold = defender.ColdResistance;
                pois = defender.PoisonResistance;
                nrgy = defender.EnergyResistance;

                int low = phys, type = 0;

                if ( fire < low ){ low = fire; type = 1; }
                if ( cold < low ){ low = cold; type = 2; }
                if ( pois < low ){ low = pois; type = 3; }
                if ( nrgy < low ){ low = nrgy; type = 4; }

                phys = fire = cold = pois = nrgy = 0;

                if ( type == 0 ) phys = 100;
                else if ( type == 1 ) fire = 100;
                else if ( type == 2 ) cold = 100;
                else if ( type == 3 ) pois = 100;
                else if ( type == 4 ) nrgy = 100;
            }

            int damageGiven = damage;

            AOS.ArmorIgnore = ( a is ArmorIgnore );

            damageGiven = AOS.Damage( defender, attacker, damage, phys, fire, cold, pois, nrgy );

            AOS.ArmorIgnore = false;

            if ( Core.AOS )
            {
                int lifeLeech = 0;//m_AosWeaponAttributes.HitLeechHits;
                int stamLeech = 0;//m_AosWeaponAttributes.HitLeechStam;
                int manaLeech = 0;//m_AosWeaponAttributes.HitLeechMana;

                if ( m_AosWeaponAttributes.HitLeechHits > Utility.Random( 100 ) )
                    lifeLeech += 30; // HitLeechHits% chance to leech 30% of damage as hit points

                if ( m_AosWeaponAttributes.HitLeechStam > Utility.Random( 100 ) )
                    stamLeech += 100; // HitLeechStam% chance to leech 100% of damage as stamina

                if ( m_AosWeaponAttributes.HitLeechMana > Utility.Random( 100 ) )
                    manaLeech += 40; // HitLeechMana% chance to leech 40% of damage as mana

                if ( m_Cursed )
                    lifeLeech += 50; // Additional 50% life leech for cursed weapons (necro spell)

                context = TransformationSpell.GetContext( attacker );

                if ( context != null && context.Type == typeof( VampiricEmbraceSpell ) )
                    lifeLeech += 20; // Vampiric embrace gives an additional 20% life leech

                if ( context != null && context.Type == typeof( WraithFormSpell ) )
                    manaLeech += (5 + (int)((15 * attacker.Skills.SpiritSpeak.Value) / 100)); // Wraith form gives an additional 5-20% mana leech

                if ( lifeLeech != 0 )
                    attacker.Hits += AOS.Scale( damageGiven, lifeLeech );

                if ( stamLeech != 0 )
                    attacker.Stam += AOS.Scale( damageGiven, stamLeech );

                if ( manaLeech != 0 )
                    attacker.Mana += AOS.Scale( damageGiven, manaLeech );

                if ( lifeLeech != 0 || stamLeech != 0 || manaLeech != 0 )
                    attacker.PlaySound( 0x44D );
            }

            if ( m_MaxHits > 0 && ((MaxRange <= 1 && (defender is Slime || defender is ToxicElemental)) || Utility.Random( 25 ) == 0) ) // Stratics says 50% chance, seems more like 4%..
            {
                if ( MaxRange <= 1 && (defender is Slime || defender is ToxicElemental) )
                    attacker.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500263 ); // *Acid blood scars your weapon!*

                if ( Core.AOS && m_AosWeaponAttributes.SelfRepair > Utility.Random( 10 ) )
                {
                    Hits += 2;
                }
                else
                {
                    if ( m_Hits > 0 )
                    {
                        --Hits;
                    }
                    else if ( m_MaxHits > 1 )
                    {
                        --MaxHits;

                        if ( Parent is Mobile )
                            ((Mobile)Parent).LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061121 ); // Your equipment is severely damaged.
                    }
                    else
                    {
                        Delete();
                    }
                }
            }

            if ( attacker is VampireBatFamiliar )
            {
                BaseCreature bc = (BaseCreature)attacker;
                Mobile caster = bc.ControlMaster;

                if ( caster == null )
                    caster = bc.SummonMaster;

                if ( caster != null && caster.Map == bc.Map && caster.InRange( bc, 2 ) )
                    caster.Hits += damage;
                else
                    bc.Hits += damage;
            }

            if ( Core.AOS )
            {
                int physChance = m_AosWeaponAttributes.HitPhysicalArea;
                int fireChance = m_AosWeaponAttributes.HitFireArea;
                int coldChance = m_AosWeaponAttributes.HitColdArea;
                int poisChance = m_AosWeaponAttributes.HitPoisonArea;
                int nrgyChance = m_AosWeaponAttributes.HitEnergyArea;

                if ( physChance != 0 && physChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x10E,   50, 100, 0, 0, 0, 0 );

                if ( fireChance != 0 && fireChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x11D, 1160, 0, 100, 0, 0, 0 );

                if ( coldChance != 0 && coldChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x0FC, 2100, 0, 0, 100, 0, 0 );

                if ( poisChance != 0 && poisChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x205, 1166, 0, 0, 0, 100, 0 );

                if ( nrgyChance != 0 && nrgyChance > Utility.Random( 100 ) )
                    DoAreaAttack( attacker, defender, 0x1F1,  120, 0, 0, 0, 0, 100 );

                int maChance = m_AosWeaponAttributes.HitMagicArrow;
                int harmChance = m_AosWeaponAttributes.HitHarm;
                int fireballChance = m_AosWeaponAttributes.HitFireball;
                int lightningChance = m_AosWeaponAttributes.HitLightning;
                int dispelChance = m_AosWeaponAttributes.HitDispel;

                if ( maChance != 0 && maChance > Utility.Random( 100 ) )
                    DoMagicArrow( attacker, defender );

                if ( harmChance != 0 && harmChance > Utility.Random( 100 ) )
                    DoHarm( attacker, defender );

                if ( fireballChance != 0 && fireballChance > Utility.Random( 100 ) )
                    DoFireball( attacker, defender );

                if ( lightningChance != 0 && lightningChance > Utility.Random( 100 ) )
                    DoLightning( attacker, defender );

                if ( dispelChance != 0 && dispelChance > Utility.Random( 100 ) )
                    DoDispel( attacker, defender );

                int laChance = m_AosWeaponAttributes.HitLowerAttack;
                int ldChance = m_AosWeaponAttributes.HitLowerDefend;

                if ( laChance != 0 && laChance > Utility.Random( 100 ) )
                    DoLowerAttack( attacker, defender );

                if ( ldChance != 0 && ldChance > Utility.Random( 100 ) )
                    DoLowerDefense( attacker, defender );
            }

            if ( attacker is BaseCreature )
                ((BaseCreature)attacker).OnGaveMeleeAttack( defender );

            if ( defender is BaseCreature )
                ((BaseCreature)defender).OnGotMeleeAttack( attacker );

            if ( a != null )
                a.OnHit( attacker, defender, damage );
        }
			private static void CopyMobProperties ( Mobile dest, Mobile src )
			{
				PropertyInfo[] props = src.GetType().GetProperties();

				for ( int i = 0; i < props.Length; i++ )
				{
					if ( props[i].CanRead && props[i].CanWrite )
						props[i].SetValue( dest, props[i].GetValue( src, null ), null );
				}
			}
Exemple #42
0
        public static bool Slays(TalismanSlayerName name, Mobile m)
        {
            if (!m_Table.ContainsKey(name))
                return false;

            Type[] types = m_Table[name];

            if (types == null || m == null)
                return false;

            Type type = m.GetType();

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssignableFrom(type))
                    return true;
            }

            return false;
        }
Exemple #43
0
        public override bool IgnoreYoungProtection(Mobile from)
        {
            if (this.Completed)
                return false;

            Type fromType = from.GetType();

            for (int i = 0; i < this.m_Images.Length; i++)
            {
                ImageTypeInfo info = ImageTypeInfo.Get(this.m_Images[i]);

                if (info.Type == fromType)
                    return true;
            }

            return false;
        }
        public String GetPetKind(Mobile pet)
        {
            if (pet == null || pet.Deleted)
            {
                return "";
            }

            String petclass = pet.GetType().ToString();
            var rx = new Regex(@"^.*\.(?<pc>.*)$");
            Match m = rx.Match(petclass);

            return m.Groups["pc"].Value;
        }
        public Item Mutate(Mobile from, int luckChance, Item item)
        {
            if (item == null)
                return null;

            if (item is BaseWeapon)
            {
                BaseWeapon weapon = (BaseWeapon)item;

                //Taran: Below we remove the items we don't want mobs to drop
                while (weapon is BaseKnife || weapon is Pickaxe || weapon is Hatchet || weapon is BaseStaff)
                {
                    weapon.Delete();
                    weapon = BaseWeapon.CreateRandomWeapon();
                }

                if (m_WeaponModifiers != null)
                    m_WeaponModifiers.Mutate(weapon);

                //if (5 > Utility.Random(100))
                //   weapon.Slayer = SlayerName.Silver;

                //if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 && weapon.Slayer == SlayerName.None && 5 > Utility.Random(100))
                //    weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType());

                weapon.Identified = true;
            }
            else if (item is BaseArmor)
            {
                BaseArmor armor = (BaseArmor)item;

                if (m_ArmorModifiers != null)
                    m_ArmorModifiers.Mutate(armor);

                armor.Identified = true;
            }
            else if (item is BaseInstrument)
            {
                SlayerName slayer = SlayerGroup.GetLootSlayerType(from.GetType());

                if (slayer == SlayerName.None)
                {
                    item.Delete();
                    return null;
                }

                BaseInstrument instr = (BaseInstrument)item;

                instr.Quality = InstrumentQuality.Regular;
                instr.Slayer = slayer;
            }

            return item;
        }
		public bool Slays(Mobile m)
		{
			Type t = m.GetType();

			return Types.Any(t1 => t1.IsAssignableFrom(t));
		}
Exemple #47
0
        public int DamageBonus(Mobile to)
        {
            if (to != null && to.GetType() == this.m_Type)
                return this.m_Amount;

            return 0;
        }
Exemple #48
0
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
                return Notoriety.Invulnerable;

            #region Dueling
            if (source is PlayerMobile && target is PlayerMobile)
            {
                PlayerMobile pmFrom = (PlayerMobile)source;
                PlayerMobile pmTarg = (PlayerMobile)target;

                if (pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext)
                    return pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy;
            }
            #endregion

            if (target.IsStaff())
                return Notoriety.CanBeAttacked;

            if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                Mobile master = bc.GetMaster();

                if (master != null && master.IsStaff())
                    return Notoriety.CanBeAttacked;

                master = bc.ControlMaster;

                if (Core.ML && master != null)
                {
                    if ((source == master && CheckAggressor(target.Aggressors, source)) || (CheckAggressor(source.Aggressors, bc)))
                        return Notoriety.CanBeAttacked;
                    else
                        return MobileNotoriety(source, master);
                }

                if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType())
                    return Notoriety.Enemy;
            }

            if (target.Kills >= 5 || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)))
                return Notoriety.Murderer;
				
            #region Mondain's Legacy
            if (target is Gregorio)
            {
                Gregorio gregorio = (Gregorio)target;

                if (Gregorio.IsMurderer(source))
                    return Notoriety.Murderer;
				
                return Notoriety.Innocent;
            }
            else if (source.Player && target is Engines.Quests.BaseEscort)
                return Notoriety.Innocent;
            #endregion

            if (target.Criminal)
                return Notoriety.Criminal;

            if (XmlPoints.AreTeamMembers(source, target))
                return Notoriety.Ally;
            else if (XmlPoints.AreChallengers(source, target))
                return Notoriety.Enemy;

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (sourceGuild != null && targetGuild != null)
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                    return Notoriety.Ally;
                else if (sourceGuild.IsEnemy(targetGuild))
                    return Notoriety.Enemy;
            }

            Faction srcFaction = Faction.Find(source, true, true);
            Faction trgFaction = Faction.Find(target, true, true);

            if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
                return Notoriety.Enemy;

            if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
                return Notoriety.CanBeAttacked;

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
                return Notoriety.CanBeAttacked;

            if (CheckHouseFlag(source, target, target.Location, target.Map))
                return Notoriety.CanBeAttacked;

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))   //If Target is NOT A baseCreature, OR it's a BC and the BC is initial innocent...
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !(target is PlayerMobile) || !Core.ML && !target.CanBeginAction(typeof(Server.Spells.Seventh.PolymorphSpell)))
                    return Notoriety.CanBeAttacked;
            }

            if (CheckAggressor(source.Aggressors, target))
                return Notoriety.CanBeAttacked;

            if (CheckAggressed(source.Aggressed, target))
                return Notoriety.CanBeAttacked;

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                    return Notoriety.CanBeAttacked;
            }

            if (source is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)source;
                Mobile master = bc.GetMaster();

                if (master != null)
                    if (CheckAggressor(master.Aggressors, target) || MobileNotoriety(master, target) == Notoriety.CanBeAttacked || target is BaseCreature)
                        return Notoriety.CanBeAttacked;
            }

            return Notoriety.Innocent;
        }
Exemple #49
0
        public static string GetCorpseName( Mobile m )
        {
            if ( m is BaseCreature )
            {
                BaseCreature bc = (BaseCreature)m;

                if ( bc.CorpseNameOverride != null )
                    return bc.CorpseNameOverride;
            }

            Type t = m.GetType();

            object[] attrs = t.GetCustomAttributes( typeof( CorpseNameAttribute ), true );

            if ( attrs != null && attrs.Length > 0 )
            {
                CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;

                if ( attr != null )
                    return attr.Name;
            }

            return null;
        }
Exemple #50
0
        public override bool IgnoreYoungProtection(Mobile from)
        {
            if (this.Completed)
                return false;

            IngredientInfo info = IngredientInfo.Get(this.Ingredient);
            Type fromType = from.GetType();

            for (int i = 0; i < info.Creatures.Length; i++)
            {
                if (fromType == info.Creatures[i])
                    return true;
            }

            return false;
        }
Exemple #51
0
        public bool Slays(Mobile m)
        {

            if (m.SpecialSlayerMechanics)
            {
                if (m.SlayerVulnerabilities.Contains(m_Name.ToString()))
                    return true;
                else
                    return false;
            }

            Type t = m.GetType();

            for (int i = 0; i < this.m_Types.Length; ++i)
            {
                if (this.m_Types[i].IsAssignableFrom(t))
                    return true;
            }

            return false;
        }
		public virtual void OnHit(Mobile attacker, Mobile defender, double damageBonus)
		{
			if (MirrorImage.HasClone(defender) && (defender.Skills.Ninjitsu.Value / 150.0) > Utility.RandomDouble())
			{
				Clone bc;

				foreach (Mobile m in defender.GetMobilesInRange(4))
				{
					bc = m as Clone;

					if (bc != null && bc.Summoned && bc.SummonMaster == defender)
					{
						attacker.SendLocalizedMessage(1063141); // Your attack has been diverted to a nearby mirror image of your target!
						defender.SendLocalizedMessage(1063140); // You manage to divert the attack onto one of your nearby mirror images.

						/*
                        * TODO: What happens if the Clone parries a blow?
                        * And what about if the attacker is using Honorable Execution
                        * and kills it?
                        */

						defender = m;
						break;
					}
				}
			}

			PlaySwingAnimation(attacker);
			PlayHurtAnimation(defender);

			attacker.PlaySound(GetHitAttackSound(attacker, defender));
			defender.PlaySound(GetHitDefendSound(attacker, defender));

			int damage = ComputeDamage(attacker, defender);

			#region Damage Multipliers
			/*
            * The following damage bonuses multiply damage by a factor.
            * Capped at x3 (300%).
            */
			int percentageBonus = 0;

			WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);
			SpecialMove move = SpecialMove.GetCurrentMove(attacker);

			if (a != null)
			{
				percentageBonus += (int)(a.DamageScalar * 100) - 100;
			}

			if (move != null)
			{
				percentageBonus += (int)(move.GetDamageScalar(attacker, defender) * 100) - 100;
			}

			percentageBonus += (int)(damageBonus * 100) - 100;

			CheckSlayerResult cs = CheckSlayers(attacker, defender);

			if (cs != CheckSlayerResult.None)
			{
				if (cs == CheckSlayerResult.Slayer)
				{
					defender.FixedEffect(0x37B9, 10, 5);
				}

				percentageBonus += 100;
			}

			if (!attacker.Player)
			{
				if (defender is PlayerMobile)
				{
					PlayerMobile pm = (PlayerMobile)defender;

					if (pm.EnemyOfOneType != null && pm.EnemyOfOneType != attacker.GetType())
					{
						percentageBonus += 100;
					}
				}
			}
			else if (!defender.Player)
			{
				if (attacker is PlayerMobile)
				{
					PlayerMobile pm = (PlayerMobile)attacker;

					if (pm.WaitingForEnemy)
					{
						pm.EnemyOfOneType = defender.GetType();
						pm.WaitingForEnemy = false;
					}

					if (pm.EnemyOfOneType == defender.GetType())
					{
						defender.FixedEffect(0x37B9, 10, 5, 1160, 0);

						percentageBonus += 50;
					}
				}
			}

			int packInstinctBonus = GetPackInstinctBonus(attacker, defender);

			if (packInstinctBonus != 0)
			{
				percentageBonus += packInstinctBonus;
			}

			if (m_InDoubleStrike)
			{
				percentageBonus -= 10;
			}

			TransformContext context = TransformationSpellHelper.GetContext(defender);

			if ((m_Slayer == SlayerName.Silver || m_Slayer2 == SlayerName.Silver) && context != null &&
				context.Spell is NecromancerSpell && context.Type != typeof(HorrificBeastSpell))
			{
				// Every necromancer transformation other than horrific beast takes an additional 25% damage
				percentageBonus += 25;
			}

			if (attacker is PlayerMobile && !(Core.ML && defender is PlayerMobile))
			{
				PlayerMobile pmAttacker = (PlayerMobile)attacker;

				if (pmAttacker.HonorActive && pmAttacker.InRange(defender, 1))
				{
					percentageBonus += 25;
				}

				if (pmAttacker.SentHonorContext != null && pmAttacker.SentHonorContext.Target == defender)
				{
					percentageBonus += pmAttacker.SentHonorContext.PerfectionDamageBonus;
				}
			}

			#region Stygian Abyss
			percentageBonus += BattleLust.GetBonus(attacker, defender);

            if (this is BaseThrown)
            {
                double dist = attacker.GetDistanceToSqrt(defender);
                int max = ((BaseThrown)this).MaxThrowRange;

                if (dist > max)
                    percentageBonus -= 47;
            }

            if (attacker.Race == Race.Gargoyle)
            {
                double perc = ((double)attacker.Hits / (double)attacker.HitsMax) * 100;

                perc = 100 - perc;
                perc /= 20;

                if (perc > 4)
                    percentageBonus += 60;
                else if (perc >= 3)
                    percentageBonus += 45;
                else if (perc >= 2)
                    percentageBonus += 30;
                else if (perc >= 1)
                    percentageBonus += 15;
            }
			#endregion

			#region Mondain's Legacy
			if (Core.ML)
			{
				BaseTalisman talisman = attacker.Talisman as BaseTalisman;

				if (talisman != null && talisman.Killer != null)
				{
					percentageBonus += talisman.Killer.DamageBonus(defender);
				}

				if (this is ButchersWarCleaver)
				{
					if (defender is Bull || defender is Cow || defender is Gaman)
					{
						percentageBonus += 100;
					}
				}
			}
			#endregion

			percentageBonus = Math.Min(percentageBonus, 300);

			damage = AOS.Scale(damage, 100 + percentageBonus);
			#endregion

			if (attacker is BaseCreature)
			{
				((BaseCreature)attacker).AlterMeleeDamageTo(defender, ref damage);
			}

			if (defender is BaseCreature)
			{
				((BaseCreature)defender).AlterMeleeDamageFrom(attacker, ref damage);
			}

			damage = AbsorbDamage(attacker, defender, damage);

			if (!Core.AOS && damage < 1)
			{
				damage = 1;
			}
			else if (Core.AOS && damage == 0) // parried
			{
				if (a != null && a.Validate(attacker) /*&& a.CheckMana( attacker, true )*/)
					// Parried special moves have no mana cost 
				{
					a = null;
					WeaponAbility.ClearCurrentAbility(attacker);

					attacker.SendLocalizedMessage(1061140); // Your attack was parried!
				}
			}

			#region Mondain's Legacy
			if (m_Immolating)
			{
				int d = ImmolatingWeaponSpell.GetImmolatingDamage(this);
				d = AOS.Damage(defender, attacker, d, 0, 100, 0, 0, 0);

				AttuneWeaponSpell.TryAbsorb(defender, ref d);

				if (d > 0)
				{
					defender.Damage(d);
				}
			}
			#endregion

            #region SA
            if (m_SearingWeapon && attacker.Mana > 0)
            {
                int d = SearingWeaponContext.Damage;

                if ((this is BaseRanged && 10 > Utility.Random(100)) || 20 > Utility.Random(100))
                {
                    AOS.Damage(defender, attacker, d, 0, 100, 0, 0, 0);
                    AOS.Damage(attacker, null, 4, false, 0, 0, 0, 0, 0, 0, 100, false, false, false);

                    defender.FixedParticles(0x36F4, 1, 11, 0x13A8, 0, 0, EffectLayer.Waist);

                    SearingWeaponContext.CheckHit(defender);
                    attacker.Mana--;
                }
            }

            bool splintering = false;
            if (m_AosWeaponAttributes.SplinteringWeapon > 0 && m_AosWeaponAttributes.SplinteringWeapon > Utility.Random(100))
            {
                if (SplinteringWeaponContext.CheckHit(attacker, defender, this))
                    splintering = true;
            }
            #endregion

			AddBlood(attacker, defender, damage);

			int phys, fire, cold, pois, nrgy, chaos, direct;

			GetDamageTypes(attacker, out phys, out fire, out cold, out pois, out nrgy, out chaos, out direct);

			if (Core.ML && this is BaseRanged)
			{
				BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;

				if (quiver != null)
				{
					quiver.AlterBowDamage(ref phys, ref fire, ref cold, ref pois, ref nrgy, ref chaos, ref direct);
				}
			}

			if (m_Consecrated)
			{
				phys = defender.PhysicalResistance;
				fire = defender.FireResistance;
				cold = defender.ColdResistance;
				pois = defender.PoisonResistance;
				nrgy = defender.EnergyResistance;

				int low = phys, type = 0;

				if (fire < low)
				{
					low = fire;
					type = 1;
				}
				if (cold < low)
				{
					low = cold;
					type = 2;
				}
				if (pois < low)
				{
					low = pois;
					type = 3;
				}
				if (nrgy < low)
				{
					low = nrgy;
					type = 4;
				}

				phys = fire = cold = pois = nrgy = chaos = direct = 0;

				if (type == 0)
				{
					phys = 100;
				}
				else if (type == 1)
				{
					fire = 100;
				}
				else if (type == 2)
				{
					cold = 100;
				}
				else if (type == 3)
				{
					pois = 100;
				}
				else if (type == 4)
				{
					nrgy = 100;
				}
			}

			// TODO: Scale damage, alongside the leech effects below, to weapon speed.
			if (ImmolatingWeaponSpell.IsImmolating(this) && damage > 0)
			{
				ImmolatingWeaponSpell.DoEffect(this, defender);
			}

			int damageGiven = damage;

			if (a != null && !a.OnBeforeDamage(attacker, defender))
			{
				WeaponAbility.ClearCurrentAbility(attacker);
				a = null;
			}

			if (move != null && !move.OnBeforeDamage(attacker, defender))
			{
				SpecialMove.ClearCurrentMove(attacker);
				move = null;
			}

			bool ignoreArmor = (a is ArmorIgnore || (move != null && move.IgnoreArmor(attacker)));

			damageGiven = AOS.Damage(
				defender,
				attacker,
				damage,
				ignoreArmor,
				phys,
				fire,
				cold,
				pois,
				nrgy,
				chaos,
				direct,
				false,
				this is BaseRanged,
				false);

            #region Stygian Abyss
            SoulChargeContext.CheckHit(attacker, defender, damageGiven);
            #endregion

			double propertyBonus = (move == null) ? 1.0 : move.GetPropertyBonus(attacker);

			if (Core.AOS)
			{
				int lifeLeech = 0;
				int stamLeech = 0;
				int manaLeech = 0;
				int wraithLeech = 0;

                if ((int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLeechHits) * propertyBonus) >
					Utility.Random(100))
				{
					lifeLeech += 30; // HitLeechHits% chance to leech 30% of damage as hit points
				}

                if ((int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLeechStam) * propertyBonus) >
					Utility.Random(100))
				{
					stamLeech += 100; // HitLeechStam% chance to leech 100% of damage as stamina
				}

				if ((int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLeechMana) * propertyBonus) >
					Utility.Random(100))
				{
					manaLeech += 40; // HitLeechMana% chance to leech 40% of damage as mana
				}

				if (m_Cursed)
				{
					lifeLeech += 50; // Additional 50% life leech for cursed weapons (necro spell)
				}

				context = TransformationSpellHelper.GetContext(attacker);

				if (context != null && context.Type == typeof(VampiricEmbraceSpell))
				{
					lifeLeech += 20; // Vampiric embrace gives an additional 20% life leech
				}

				if (context != null && context.Type == typeof(WraithFormSpell))
				{
					wraithLeech = (5 + (int)((15 * attacker.Skills.SpiritSpeak.Value) / 100));
						// Wraith form gives an additional 5-20% mana leech

					// Mana leeched by the Wraith Form spell is actually stolen, not just leeched.
					defender.Mana -= AOS.Scale(damageGiven, wraithLeech);

					manaLeech += wraithLeech;
				}

				if (lifeLeech != 0)
				{
                    int toHeal = AOS.Scale(damageGiven, lifeLeech);
                    #region High Seas
                    if (defender is BaseCreature && ((BaseCreature)defender).TaintedLifeAura)
                    {
                        AOS.Damage(attacker, defender, toHeal, false, 0, 0, 0, 0, 0, 0, 100, false, false, false);
                        attacker.SendLocalizedMessage(1116778); //The tainted life force energy damages you as your body tries to absorb it.
                    }
                    else
                        attacker.Hits += toHeal;
                    #endregion
				}

				if (stamLeech != 0)
				{
					attacker.Stam += AOS.Scale(damageGiven, stamLeech);
				}

				if (manaLeech != 0)
				{
					attacker.Mana += AOS.Scale(damageGiven, manaLeech);
				}

				if (lifeLeech != 0 || stamLeech != 0 || manaLeech != 0)
				{
					attacker.PlaySound(0x44D);
				}
			}

			if (m_MaxHits > 0 &&
				((MaxRange <= 1 && (defender is Slime || defender is ToxicElemental || defender is CorrosiveSlime)) || splintering ||
				 Utility.Random(25) == 0)) // Stratics says 50% chance, seems more like 4%..
			{
				if (MaxRange <= 1 && (defender is Slime || defender is ToxicElemental || defender is CorrosiveSlime))
				{
					attacker.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500263); // *Acid blood scars your weapon!*
				}

				if (Core.AOS &&
					m_AosWeaponAttributes.SelfRepair + (IsSetItem && m_SetEquipped ? m_SetSelfRepair : 0) > Utility.Random(10))
				{
					HitPoints += 2;
				}
				else
				{
					if (m_Hits > 0)
					{
						--HitPoints;
					}
					else if (m_MaxHits > 1)
					{
						--MaxHitPoints;

						if (Parent is Mobile)
						{
							((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121);
								// Your equipment is severely damaged.
						}
					}
					else
					{
						Delete();
					}
				}
			}

			if (attacker is VampireBatFamiliar)
			{
				BaseCreature bc = (BaseCreature)attacker;
				Mobile caster = bc.ControlMaster;

				if (caster == null)
				{
					caster = bc.SummonMaster;
				}

				if (caster != null && caster.Map == bc.Map && caster.InRange(bc, 2))
				{
					caster.Hits += damage;
				}
				else
				{
					bc.Hits += damage;
				}
			}

			if (Core.AOS)
			{
				int physChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitPhysicalArea) * propertyBonus);
				int fireChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitFireArea) * propertyBonus);
				int coldChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitColdArea) * propertyBonus);
				int poisChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitPoisonArea) * propertyBonus);
				int nrgyChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitEnergyArea) * propertyBonus);

				if (physChance != 0 && physChance > Utility.Random(100))
				{
					DoAreaAttack(attacker, defender, 0x10E, 50, 100, 0, 0, 0, 0);
				}

				if (fireChance != 0 && fireChance > Utility.Random(100))
				{
					DoAreaAttack(attacker, defender, 0x11D, 1160, 0, 100, 0, 0, 0);
				}

				if (coldChance != 0 && coldChance > Utility.Random(100))
				{
					DoAreaAttack(attacker, defender, 0x0FC, 2100, 0, 0, 100, 0, 0);
				}

				if (poisChance != 0 && poisChance > Utility.Random(100))
				{
					DoAreaAttack(attacker, defender, 0x205, 1166, 0, 0, 0, 100, 0);
				}

				if (nrgyChance != 0 && nrgyChance > Utility.Random(100))
				{
					DoAreaAttack(attacker, defender, 0x1F1, 120, 0, 0, 0, 0, 100);
				}

				int maChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitMagicArrow) * propertyBonus);
				int harmChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitHarm) * propertyBonus);
				int fireballChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitFireball) * propertyBonus);
				int lightningChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLightning) * propertyBonus);
				int dispelChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitDispel) * propertyBonus);

				#region Stygian Abyss
				int curseChance = (int)(m_AosWeaponAttributes.HitCurse * propertyBonus);
				int fatigueChance = (int)(m_AosWeaponAttributes.HitFatigue * propertyBonus);
				int manadrainChance = (int)(m_AosWeaponAttributes.HitManaDrain * propertyBonus);
				#endregion

				if (maChance != 0 && maChance > Utility.Random(100))
				{
					DoMagicArrow(attacker, defender);
				}

				if (harmChance != 0 && harmChance > Utility.Random(100))
				{
					DoHarm(attacker, defender);
				}

				if (fireballChance != 0 && fireballChance > Utility.Random(100))
				{
					DoFireball(attacker, defender);
				}

				if (lightningChance != 0 && lightningChance > Utility.Random(100))
				{
					DoLightning(attacker, defender);
				}

				if (dispelChance != 0 && dispelChance > Utility.Random(100))
				{
					DoDispel(attacker, defender);
				}

				#region Stygian Abyss
				if (curseChance != 0 && curseChance > Utility.Random(100))
				{
					DoCurse(attacker, defender);
				}

				if (fatigueChance != 0 && fatigueChance > Utility.Random(100))
				{
					DoFatigue(attacker, defender, damageGiven);
				}

				if (manadrainChance != 0 && manadrainChance > Utility.Random(100))
				{
					DoManaDrain(attacker, defender, damageGiven);
				}
				#endregion

				int laChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLowerAttack) * propertyBonus);
				int ldChance = (int)(AosWeaponAttributes.GetValue(attacker, AosWeaponAttribute.HitLowerDefend) * propertyBonus);

				if (laChance != 0 && laChance > Utility.Random(100))
				{
					DoLowerAttack(attacker, defender);
				}

				if (ldChance != 0 && ldChance > Utility.Random(100))
				{
					DoLowerDefense(attacker, defender);
				}
			}

			if (attacker is BaseCreature)
			{
				((BaseCreature)attacker).OnGaveMeleeAttack(defender);
			}

			if (defender is BaseCreature)
			{
				((BaseCreature)defender).OnGotMeleeAttack(attacker);
			}

			if (a != null)
			{
				a.OnHit(attacker, defender, damage);
			}

			if (move != null)
			{
				move.OnHit(attacker, defender, damage);
			}

			if (defender is IHonorTarget && ((IHonorTarget)defender).ReceivedHonorContext != null)
			{
				((IHonorTarget)defender).ReceivedHonorContext.OnTargetHit(attacker);
			}

			if (!(this is BaseRanged))
			{
				if (AnimalForm.UnderTransformation(attacker, typeof(GiantSerpent)))
				{
					defender.ApplyPoison(attacker, Poison.Lesser);
				}

				if (AnimalForm.UnderTransformation(defender, typeof(BullFrog)))
				{
					attacker.ApplyPoison(defender, Poison.Regular);
				}
			}

			XmlAttach.OnWeaponHit(this, attacker, defender, damageGiven);
		}
Exemple #53
0
        public static string GetCorpseName(Mobile m)
        {
            XmlData x = (XmlData)XmlAttach.FindAttachment(m, typeof(XmlData), "CorpseName");
  			
            if (x != null)
                return x.Data;

            if (m is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)m;

                if (bc.CorpseNameOverride != null)
                    return bc.CorpseNameOverride;
            }

            Type t = m.GetType();

            object[] attrs = t.GetCustomAttributes(typeof(CorpseNameAttribute), true);

            if (attrs != null && attrs.Length > 0)
            {
                CorpseNameAttribute attr = attrs[0] as CorpseNameAttribute;

                if (attr != null)
                    return attr.Name;
            }

            return null;
        }
		public int DamageBonus( Mobile to )
		{
			if ( to != null && to.GetType() == m_Type ) // Verified: only works on the exact type
				return m_Amount;

			return 0;
		}
Exemple #55
0
		public static int MobileNotoriety( Mobile source, Mobile target )
		{
		    CustomRegion cR = target.Region as CustomRegion;

            #region Event Notorieties

            //Check event prop first for better use of resources
            if ((source.IsInEvent && !target.IsInEvent) && (cR == null || cR.Controller.HasAttackPenalty))
                return Notoriety.Invulnerable;
            if ((!source.IsInEvent && target.IsInEvent) && (cR == null || cR.Controller.HasAttackPenalty))
                return Notoriety.Invulnerable;

            //Deathmatch
            if (Custom.PvpToolkit.PvpCore.IsInDeathmatch(source) && Custom.PvpToolkit.PvpCore.IsInDeathmatch(target))
            {
                Custom.PvpToolkit.DMatch.Items.DMStone dm1 = Custom.PvpToolkit.PvpCore.GetPlayerStone(source);
                Custom.PvpToolkit.DMatch.Items.DMStone dm2 = Custom.PvpToolkit.PvpCore.GetPlayerStone(target);

                return dm1 == dm2 ? Notoriety.Enemy : Notoriety.Invulnerable;
            }

            //Tournament
            if (Custom.PvpToolkit.Tournament.TournamentCore.IsInTournament(source) && Custom.PvpToolkit.Tournament.TournamentCore.IsInTournament(target))
		    {
                Custom.PvpToolkit.Tournament.TournamentStone stone1 = Custom.PvpToolkit.Tournament.TournamentCore.GetPlayerStone(source);
                Custom.PvpToolkit.Tournament.TournamentStone stone2 = Custom.PvpToolkit.Tournament.TournamentCore.GetPlayerStone(target);

                return stone1 == stone2 ? Notoriety.Enemy : Notoriety.Invulnerable;
		    }

		    //Capture the Flag / Color Wars / Double Dom games
            if (source is PlayerMobile && target is PlayerMobile)
            {
                PlayerMobile src = source as PlayerMobile;
                PlayerMobile trg = target as PlayerMobile;
                BaseTeamGame srcevent = src.CurrentEvent as BaseTeamGame;
                BaseTeamGame trgevent = trg.CurrentEvent as BaseTeamGame;
                if (srcevent != null && trgevent != null)
                {
                    BaseGameTeam srcteam = srcevent.GetTeam(source);
                    if (srcteam != null)
                    {
                        BaseGameTeam trgteam = srcevent.GetTeam(target);
                        if (trgteam != null)
                            return srcteam == trgteam ? Notoriety.Ally : Notoriety.Enemy;
                    }
                }
            }

            #endregion

            if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
                return Notoriety.Invulnerable;

            if (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead))
                return Notoriety.Murderer;

            if ( target is PlayerMobile && (((PlayerMobile)target).AlwaysMurderer))
                return Notoriety.Murderer;

            //All mobiles have same murder rules.
            if (target.Kills >= KILLS_FOR_MURDER)
                return Notoriety.Murderer;

            //Target should be karma red before guild notoriety
            if (target is PlayerMobile)
            {
                if (target.Karma <= PLAYER_KARMA_RED)
                    return Notoriety.Murderer;
            }

		    Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (sourceGuild != null && targetGuild != null)
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild) || (sourceGuild.Type !=
                    GuildType.Regular && sourceGuild.Type == targetGuild.Type))
                    return Notoriety.Ally;
                if (sourceGuild.IsEnemy(targetGuild))
                    return Notoriety.Enemy;
            }

		    if (cR != null && !cR.Controller.HasAttackPenalty)
                return Notoriety.CanBeAttacked;

            if (target.AccessLevel > AccessLevel.Player)
                return Notoriety.CanBeAttacked;

            if (target is PlayerMobile) //Player mobile notoriety hierarchy
            {
                if (target.Criminal)
                    return Notoriety.Criminal;
                if (target.Karma <= PLAYER_KARMA_GREY)
                    return Notoriety.CanBeAttacked;
            }
            else //Mobile notoriety hierarchy
            {
                if (target.Karma <= NPC_KARMA_RED)
                    return Notoriety.Murderer;
                if (target.Criminal)
                    return Notoriety.Criminal;
                if (target.Karma <= NPC_KARMA_GREY)
                    return Notoriety.CanBeAttacked;
            }

			if( source.Player && !target.Player && source is PlayerMobile && target is BaseCreature )
			{
				BaseCreature bc = (BaseCreature)target;

                Mobile master = bc.GetMaster();

                if (master != null && master.AccessLevel > AccessLevel.Player)
                    return Notoriety.CanBeAttacked;

				if( !bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType() )
					return Notoriety.Enemy;

                if (bc.ControlMaster == source)
                    return Notoriety.CanBeAttacked;

                master = bc.ControlMaster;

                if (Core.ML && master != null)
                {
                    if (source == master && CheckAggressor(target.Aggressors, source))
                        return Notoriety.CanBeAttacked;

                    return MobileNotoriety(source, master);
                }
			}


			Faction srcFaction = Faction.Find( source, true, true );
			Faction trgFaction = Faction.Find( target, true, true );

			if( srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet )
				return Notoriety.Enemy;

            if (Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
                return Notoriety.CanBeAttacked;

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
                return Notoriety.CanBeAttacked;

            if (!IsGuardCandidate(target) && (target is BaseGuard))
                return Notoriety.Innocent;

            //Maka - Repo update, might mess stuff upp
            //Taran - Yeah it did, I had to uncomment it :P
            //if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            //{
            //  if( !target.Body.IsHuman && !target.Body.IsGhost && !IsPet( target as BaseCreature ) && !TransformationSpellHelper.UnderTransformation( target ) && !AnimalForm.UnderTransformation( target ) )
            //      return Notoriety.CanBeAttacked;
            //}

            if (CheckAggressor(source.Aggressors, target))
                return Notoriety.CanBeAttacked;

            if (CheckAggressed(source.Aggressed, target))
                return Notoriety.CanBeAttacked;

			if( target is BaseCreature )
			{
				BaseCreature bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                    return Notoriety.CanBeAttacked;
			}

			if( source is BaseCreature )
			{
				BaseCreature bc = (BaseCreature)source;

				Mobile master = bc.GetMaster();
                if (master != null && CheckAggressor(master.Aggressors, target))
                    return Notoriety.CanBeAttacked;
			}

			return Notoriety.Innocent;
		}
        public int GetRankFor(Mobile m)
        {
            Type[][] types = ChampionSpawnInfo.GetInfo(this.m_Type).SpawnTypes;
            Type t = m.GetType();

            for (int i = 0; i < types.GetLength(0); i++)
            {
                Type[] individualTypes = types[i];

                for (int j = 0; j < individualTypes.Length; j++)
                {
                    if (t == individualTypes[j])
                        return i;
                }
            }

            return -1;
        }
Exemple #57
0
        public virtual bool IsObjective(Mobile mob)
        { 
            if (this.m_Creature == null)
                return false;
		
            if (this.m_Creature.IsAssignableFrom(mob.GetType()))
            {
                if (this.m_Region != null && !this.m_Region.Contains(mob.Location))
                    return false;
					
                return true;
            }
			
            return false;
        }
Exemple #58
0
        public virtual void OnHit( Mobile attacker, Mobile defender, double damageBonus )
        {
            if ( MirrorImage.HasClone( defender ) && (defender.Skills.Ninjitsu.Value / 150.0) > Utility.RandomDouble() )
            {
                Clone bc;

                foreach ( Mobile m in defender.GetMobilesInRange( 4 ) )
                {
                    bc = m as Clone;

                    if ( bc != null && bc.Summoned && bc.SummonMaster == defender )
                    {
                        attacker.SendLocalizedMessage( 1063141 ); // Your attack has been diverted to a nearby mirror image of your target!
                        defender.SendLocalizedMessage( 1063140 ); // You manage to divert the attack onto one of your nearby mirror images.

                        /*
                         * TODO: What happens if the Clone parries a blow?
                         * And what about if the attacker is using Honorable Execution
                         * and kills it?
                         */

                        defender = m;
                        break;
                    }
                }
            }

            PlaySwingAnimation( attacker );
            PlayHurtAnimation( defender );

            attacker.PlaySound( GetHitAttackSound( attacker, defender ) );
            defender.PlaySound( GetHitDefendSound( attacker, defender ) );

            int damage = ComputeDamage( attacker, defender );

            CheckSlayerResult cs = CheckSlayers( attacker, defender );

            if ( cs != CheckSlayerResult.None )
            {
                if ( cs == CheckSlayerResult.Slayer )
                    defender.FixedEffect( 0x37B9, 10, 5 );

                damage *= 2;
            }

            if ( !attacker.Player )
            {
                if ( defender is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)defender;

                    if ( pm.EnemyOfOneType != null && pm.EnemyOfOneType != attacker.GetType() )
                        damage *= 2;
                }
            }
            else if ( !defender.Player )
            {
                if ( attacker is PlayerMobile )
                {
                    PlayerMobile pm = (PlayerMobile)attacker;

                    if ( pm.WaitingForEnemy )
                    {
                        pm.EnemyOfOneType = defender.GetType();
                        pm.WaitingForEnemy = false;
                    }

                    if ( pm.EnemyOfOneType == defender.GetType() )
                    {
                        defender.FixedEffect( 0x37B9, 10, 5, 1160, 0 );
                        damage += AOS.Scale( damage, 50 );
                    }
                }
            }

            int packInstinctBonus = GetPackInstinctBonus( attacker, defender );

            if ( packInstinctBonus != 0 )
                damage += AOS.Scale( damage, packInstinctBonus );

            if ( m_InDoubleStrike )
                damage -= AOS.Scale( damage, 10 ); // 10% loss when attacking with double-strike

            if ( attacker is BaseCreature )
                ((BaseCreature)attacker).AlterMeleeDamageTo( defender, ref damage );

            if ( defender is BaseCreature )
                ((BaseCreature)defender).AlterMeleeDamageFrom( attacker, ref damage );

            WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );

            damage = AbsorbDamage( attacker, defender, damage );

            // pre-aos, if defender is player or attacker is not a player, halve damage
            if ( !Core.AOS && ((defender is PlayerMobile) || !(attacker is PlayerMobile || attacker.Body.IsHuman)) )
                damage = (int)(damage / 2.0);

            if ( !Core.AOS && damage < 1 )
                damage = 1;
            else if ( Core.AOS && damage == 0 ) // parried
            {
                // TODO: Is this accurate?
                if ( a != null && a.Validate( attacker ) && a.CheckMana( attacker, true ) ) // mana is consumed
                {
                    a = null;
                    WeaponAbility.ClearCurrentAbility( attacker );

                    attacker.SendLocalizedMessage( 1061140 ); // Your attack was parried!
                }
            }

            AddBlood( attacker, defender, damage );

            int phys, fire, cold, pois, nrgy;

            GetDamageTypes( attacker, out phys, out fire, out cold, out pois, out nrgy );

            if ( m_Consecrated )
            {
                phys = defender.PhysicalResistance;
                fire = defender.FireResistance;
                cold = defender.ColdResistance;
                pois = defender.PoisonResistance;
                nrgy = defender.EnergyResistance;

                int low = phys, type = 0;

                if ( fire < low ){ low = fire; type = 1; }
                if ( cold < low ){ low = cold; type = 2; }
                if ( pois < low ){ low = pois; type = 3; }
                if ( nrgy < low ){ low = nrgy; type = 4; }

                phys = fire = cold = pois = nrgy = 0;

                if ( type == 0 ) phys = 100;
                else if ( type == 1 ) fire = 100;
                else if ( type == 2 ) cold = 100;
                else if ( type == 3 ) pois = 100;
                else if ( type == 4 ) nrgy = 100;
            }

            // int damageGiven = damage;

            //AOS.ArmorIgnore = ( a is ArmorIgnore );

            int damageGiven = AOS.Damage( defender, attacker, damage, phys, fire, cold, pois, nrgy );

            //AOS.ArmorIgnore = false;

            if ( Core.AOS )
            {
                int lifeLeech = 0;//m_AosWeaponAttributes.HitLeechHits;
                int stamLeech = 0;//m_AosWeaponAttributes.HitLeechStam;
                int manaLeech = 0;//m_AosWeaponAttributes.HitLeechMana;

                if ( m_AosWeaponAttributes.HitLeechHits > Utility.Random( 100 ) )
                    lifeLeech += 30; // HitLeechHits% chance to leech 30% of damage as hit points

                if ( m_AosWeaponAttributes.HitLeechStam > Utility.Random( 100 ) )
                    stamLeech += 100; // HitLeechStam% chance to leech 100% of damage as stamina

                if ( m_AosWeaponAttributes.HitLeechMana > Utility.Random( 100 ) )
                    manaLeech += 40; // HitLeechMana% chance to leech 40% of damage as mana

                if ( m_Cursed )
                    lifeLeech += 50; // Additional 50% life leech for cursed weapons (necro spell)

                if ( lifeLeech != 0 )
                    attacker.Hits += AOS.Scale( damageGiven, lifeLeech );

                if ( stamLeech != 0 )
                    attacker.Stam += AOS.Scale( damageGiven, stamLeech );

                if ( manaLeech != 0 )
                    attacker.Mana += AOS.Scale( damageGiven, manaLeech );
            }

            if ( m_MaxHits > 0 && ((MaxRange <= 1 && (defender is Slime || defender is ToxicElemental)) || Utility.Random( 10 ) == 0) ) // Stratics says 50% chance, seems more like 5%..
            {
                if ( MaxRange <= 1 && (defender is Slime || defender is ToxicElemental) )
                    attacker.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500263 ); // *Acid blood scars your weapon!*

                if ( Core.AOS && m_AosWeaponAttributes.SelfRepair > Utility.Random( 10 ) )
                {
                    HitPoints += 2;
                }
                else
                {
                    if ( m_Hits > 0 )
                    {
                        --HitPoints;
                    }

                    if ( m_Hits < 10 || ((float)HitPoints / MaxHitPoints) <= 0.1 )
                    {
                        if ( MaxHitPoints == 1 && m_Hits <= 0 )
                        {
                            if (Parent is Mobile)
                                ((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, true, "Your equipment has been destroyed!");
                            Delete();
                        }
                        else
                        {
                            --MaxHitPoints;

                            if (Parent is Mobile)
                                ((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121); // Your equipment is severely damaged.
                        }
                    }
                }
            }

            if (SpellEffectOnHit && defender.Alive && !defender.Deleted && m_Effect != SpellEffect.None && m_EffectCharges > 0)
            {
                if (SpellCastEffect.InvokeEffect(m_Effect, attacker, defender))
                {
                    SpellCharges--;
                    if (SpellCharges <= 0)
                    {
                        m_Effect = SpellEffect.None;
                        attacker.SendAsciiMessage("This magic item is out of charges.");
                    }
                }
            }

            if ( attacker is BaseCreature )
                ((BaseCreature)attacker).OnGaveMeleeAttack( defender );

            if ( defender is BaseCreature )
                ((BaseCreature)defender).OnGotMeleeAttack( attacker );

            if ( a != null )
                a.OnHit( attacker, defender, damage );

            if ( defender is IHonorTarget && ((IHonorTarget)defender).ReceivedHonorContext != null )
                ((IHonorTarget)defender).ReceivedHonorContext.OnTargetHit( attacker );

            if ( !(this is BaseRanged) )
            {
                if ( AnimalForm.UnderTransformation( attacker, typeof( GiantSerpent ) ) )
                    defender.ApplyPoison( attacker, Poison.Lesser );

                if ( AnimalForm.UnderTransformation( defender, typeof( BullFrog ) ) )
                    attacker.ApplyPoison( defender, Poison.Regular );
            }

            Server.Engines.XmlSpawner2.XmlAttach.OnWeaponHit(this, attacker, defender, damageGiven); // hook for attachment OnWeaponHit method

            if (!Core.AOS && Poison != null && PoisonCharges > 0)
            {
                --PoisonCharges;

                if (Utility.RandomDouble() < m_PoisonChance && !defender.Poisoned)
                    defender.ApplyPoison(attacker, Poison);
            }
        }
		public override void Damage( int amount, Mobile from )
		{
			if ( Spells.Necromancy.EvilOmenSpell.TryEndEffect( this ) )
				amount = (int)(amount * 1.25);

			Mobile oath = Spells.Necromancy.BloodOathSpell.GetBloodOath( from );

				/* Per EA's UO Herald Pub48 (ML):
				 * ((resist spellsx10)/20 + 10=percentage of damage resisted)
				 */

			if ( oath == this )
			{
				amount = (int)(amount * 1.1);

				if( amount > 35 && from is PlayerMobile )  /* capped @ 35, seems no expansion */
				{
					amount = 35;
				}

				if( Core.ML )
				{
					from.Damage( (int)(amount * ( 1 - ((( from.Skills.MagicResist.Value * .5 ) + 10) / 100 ))), this );
				}
				else
				{
					from.Damage( amount, this );
				}
			}

			if ( from != null && Talisman is BaseTalisman )
			{
				BaseTalisman talisman = (BaseTalisman) Talisman;

				if ( talisman.Protection != null && talisman.Protection.Type != null )
				{
					Type type = talisman.Protection.Type;

					if ( type == from.GetType() )
						amount *= 1 - (int) ( ( (double) talisman.Protection.Amount ) / 100 );
				}
			}
			base.Damage( amount, from );
		}
Exemple #60
0
        // note that this method will be called when attached to either a mobile or a weapon
        // when attached to a weapon, only that weapon will do additional damage
        // when attached to a mobile, any weapon the mobile wields will do additional damage
        public override void OnWeaponHit(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven)
        {
            if (this.m_Chance <= 0 || Utility.Random(100) > this.m_Chance)
                return;

            if (defender != null && attacker != null && this.m_EnemyType != null)
            {
                // is the defender the correct type?
                if (defender.GetType() == this.m_EnemyType || defender.GetType().IsSubclassOf(this.m_EnemyType))
                {
                    defender.Damage((int)(damageGiven * this.PercentIncrease / 100), attacker);
                }
            }
        }