public override Tuple<Item[],int> GenerateLootItem( Mobile creature )
		{
			Type type = m_InstrumentTypes[Utility.Random(m_InstrumentTypes.Length)];
			BaseInstrument instrument = Activator.CreateInstance( type ) as BaseInstrument;

			if ( instrument == null )
				throw new Exception( String.Format( "Type {0} is not BaseInstrument or could not be instantiated.", type ) );

			int value = 50;

			if ( m_SlayerChance > Utility.RandomDouble() )
			{
				if ( creature != null )
					instrument.Slayer = SlayerGroup.GetLootSlayerType( creature.GetType() );
				else
					instrument.Slayer = BaseRunicTool.GetRandomSlayer();

				value += 100;
			}

			if ( 0.08 > Utility.RandomDouble() ) // chance that this is low quality
			{
				instrument.Quality = InstrumentQuality.Low;
				value -= 50;
			}

			return new Tuple<Item[], int>( new Item[]{ instrument }, value );
		}
Example #2
0
        public bool Slays( Mobile m )
        {
            Type t = m.GetType();

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

            return false;
        }
Example #3
0
        public void OnHit( Mobile defender )
        {
            if ( m_TargetType == null )
            {
                m_TargetType = defender.GetType();

                // Odd but OSI recalculates when the target changes...
                int chivalry = (int) m_Owner.Skills.Chivalry.Value;
                m_DamageScalar = 10 + ( ( chivalry - 40 ) * 9 ) / 10;

                DeltaEnemies();
                UpdateBuffInfo();
            }
        }
		public override void OnHit( Mobile attacker, Mobile defender, double damageBonus )
		{
			bool bonus = false;
			Type t = defender.GetType();

			for( int i = 0; i < SlayerVs.Length; i++ )
			{
				if ( t == SlayerVs[i] )
				{
					bonus = true;
					break;
				}
			}

			if ( bonus )
				base.OnHit( attacker, defender, damageBonus + 2.0 );
			else
				base.OnHit( attacker, defender, damageBonus );
		}
		public override bool IgnoreYoungProtection( Mobile from )
		{
			if ( 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;
		}
		public override void OnKill(Mobile killed, Mobile killer )
		{
			base.OnKill(killed, killer);

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

			if(killed == null || killer == null || killer == killed) return;
		    
			// check for within guild kills and ignore them
			if(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;

			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 = GetFactionLevel(ally.GroupType) - facloss;
							SetFactionLevel(ally.GroupType, p);
							if(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 = GetFactionLevel(opp.GroupType) + facgain;
							SetFactionLevel(opp.GroupType, p);
							if(verboseMobFactions)
								killer.SendMessage("gained {0} faction {1}",opp.GroupType, facgain);
						}
					}
				}
			}

			m_EndTime = DateTime.Now + Refractory;
		}
Example #7
0
		public static void HandleKill( PlayerMobile pm, Mobile mob )
		{
			MLQuestContext context = GetContext( pm );

			if ( context == null )
				return;

			List<MLQuestInstance> instances = context.QuestInstances;

			Type type = null;

			for ( int i = instances.Count - 1; i >= 0; --i )
			{
				MLQuestInstance instance = instances[i];

				if ( instance.ClaimReward )
					continue;

				/* A kill only counts for a single objective within a quest,
				 * but it can count for multiple quests. This is something not
				 * currently observable on OSI, so it is assumed behavior.
				 */
				foreach ( BaseObjectiveInstance objective in instance.Objectives )
				{
					if ( !objective.Expired && objective is KillObjectiveInstance )
					{
						KillObjectiveInstance kill = (KillObjectiveInstance)objective;

						if ( type == null )
							type = mob.GetType();

						if ( kill.AddKill( mob, type ) )
						{
							kill.CheckComplete();
							break;
						}
					}
				}
			}
		}
Example #8
0
		public Item Mutate(Mobile from, Item item)
		{           

			if (item != null && !(item is BaseWand))
			{
				if (item is BaseWeapon && 1 > Utility.Random(100))
				{
					item.Delete();
					item = new FireHorn();
					return item;
				}

				if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat)
				{
					if (item is BaseWeapon)
					{
						var weapon = (BaseWeapon)item;

						if (55 > Utility.Random(100))
						{
							weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus();
						}

						if (45 > Utility.Random(100))
						{
							int damageLevel = GetRandomOldBonus();

							if (PseudoSeerStone.Instance != null && PseudoSeerStone.Instance._HighestDamageLevelSpawn < damageLevel)
							{
								if (damageLevel == 5 && PseudoSeerStone.ReplaceVanqWithSkillScrolls)
								{
									return PuzzleChest.CreateRandomSkillScroll();
								}
								int platAmount = PseudoSeerStone.PlatinumPerMissedDamageLevel *
												 (damageLevel - PseudoSeerStone.Instance._HighestDamageLevelSpawn);
								if (platAmount > 0)
								{
									return (new Platinum(platAmount));
								}
								damageLevel = PseudoSeerStone.Instance._HighestDamageLevelSpawn;
							}
							weapon.DamageLevel = (WeaponDamageLevel)damageLevel;
						}

						if (25 > Utility.Random(100))
						{
							weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus();
						}

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

						if (1 > Utility.Random(1000) ||
							(weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 &&
							 weapon.Slayer == SlayerName.None && 5 > Utility.Random(100)))
						{
							weapon.Slayer = from != null ? SlayerGroup.GetLootSlayerType(from.GetType()) : BaseRunicTool.GetRandomSlayer();
						}

						if (weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && weapon.DurabilityLevel == 0 &&
							weapon.Slayer == SlayerName.None)
						{
							weapon.Identified = true;
						}
					}
					else if (item is BaseArmor)
					{
						var armor = (BaseArmor)item;

						if (55 > Utility.Random(100))
						{
							armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus();
						}

						if (25 > Utility.Random(100))
						{
							armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus();
						}

						if (armor.ProtectionLevel == 0 && armor.Durability == 0)
						{
							armor.Identified = true;
						}
					}
				}
				else if (item is BaseInstrument)
				{
					SlayerName slayer = from == null || from.EraAOS
											? BaseRunicTool.GetRandomSlayer()
											: SlayerGroup.GetLootSlayerType(from.GetType());

					var instr = (BaseInstrument)item;

					instr.Quality = InstrumentQuality.Regular;
					instr.Slayer = slayer;
				}
				else if (item is Spellbook) //Randomize spellbook
				{
					var book = item as Spellbook;

					if (MaxIntensity == 100 && MinIntensity / 1000.0 > Utility.RandomDouble())
					{
						book.LootType = LootType.Blessed;
					}

					if (MaxIntensity == 100 && MinIntensity >= 50 && (MinIntensity / 3000.0 > Utility.RandomDouble()))
					{
						book.Dyable = true;
					}

					int rnd = Utility.RandomMinMax(MinIntensity, MaxIntensity);
					var circle = (int)((rnd / 12.5) + 1.0);

					if (circle >= 8 && 0.33 > Utility.RandomDouble())
					{
						book.Content = ulong.MaxValue;
					}
					else
					{
						circle = Math.Min(circle, 8);

						//do we fill this circle?
						for (int i = 0; i < circle; i++)
						{
							if (Utility.RandomBool())
							{
								book.Content |= (ulong)Utility.Random(0x100) << (i * 8);
							}
						}
					}
				}

				if (item.Stackable)
				{
                    // Note: do not check hits max here if you want to multiply against gold
                    // the max hits have not been set when this function is called
                    // The inital loot is added to the BaseCreature before the attributes are set
                    // for the specific mob type
				    if (item is Gold)
				    {
				        item.Amount = (int) Math.Ceiling(Quantity.Roll() * DynamicSettingsController.GoldMulti);                        
				    }
				    else
				    {
                        item.Amount = Quantity.Roll();
				    }
				}
			}

			return item;
		}
		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;
		}
Example #10
0
        public int GetSubLevelFor(Mobile m)
        {
            Type[][] types = ChampionSpawnInfo.GetInfo(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;
        }
Example #11
0
		public static string GetBodyName( Mobile m )
		{
			Type t = m.GetType();

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

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

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

			return m.Name;
		}
Example #12
0
        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 )
                    return attr.Name;
            }

            return null;
        }
Example #13
0
 public static int GetSaveFlag(Mobile m)
 {
     return ConversionTable.IndexOf(m.GetType()) + Offset;
 }
		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);
		}
Example #15
0
        public virtual bool IsObjective( Mobile mob )
        {
            if ( m_Creatures == null )
                return false;

            if ( m_Region != null && !m_Region.Contains( mob.Location ) )
                return false;

            for ( int i = 0; i < m_Creatures.Length; i++ )
            {
                Type creature = m_Creatures[i];

                if ( creature.IsAssignableFrom( mob.GetType() ) )
                    return true;
            }

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

			return 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;
		}
Example #18
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;

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

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

				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 Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)) )
				return Notoriety.Murderer;

if ( target.Criminal )
 return Notoriety.Criminal;

// XmlPoints challenge mod
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.Body.IsHuman && !target.Body.IsGhost && !IsPet( target as BaseCreature ) && !Server.Spells.Necromancy.TransformationSpell.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;
			}
			
			if ( PlayerGovernmentSystem.CheckIfBanned( source, target ) )
				return Notoriety.Enemy;

			if ( PlayerGovernmentSystem.CheckAtWarWith( source, target ) )
				return Notoriety.Enemy;

			if ( PlayerGovernmentSystem.CheckCityAlly( source, target ) )
				return Notoriety.Ally;

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

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

            return m.Groups["pc"].Value;
        }
Example #20
0
		public override bool IgnoreYoungProtection( Mobile from )
		{
			if ( Completed )
				return false;

			Type fromType = from.GetType();

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

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

			return false;
		}
Example #21
0
        public bool IsObjective( Mobile m )
        {
            if ( !m_TargetTypes.Any( t => t.IsAssignableFrom( m.GetType() ) ) )
                return false;

            if ( m_Targets.Contains( m ) )
                return false;

            return true;
        }
Example #22
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( (int) (damageGiven*PercentIncrease/100), attacker );
				}
			}
		}
Example #23
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;

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

            // MODIFICATIONS FOR Capture the Flag / Double Dom games
            Server.Items.CTFTeam ft = Server.Items.CTFGame.FindTeamFor( source );
            if ( ft != null )
            {
                Server.Items.CTFTeam tt = Server.Items.CTFGame.FindTeamFor( target );
                if ( tt != null && ft.Game == tt.Game )
                    return ft == tt ? Notoriety.Ally : Notoriety.Enemy;
            }

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

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

            if ( target.Kills >= 5 || (target.Body.IsMonster && IsSummoned( target as BaseCreature ) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)) )
                return Notoriety.Murderer;

            if ( target.Criminal )
                return Notoriety.Criminal;

            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.Body.IsHuman && !target.Body.IsGhost && !IsPet( target as BaseCreature ) && !Server.Spells.Necromancy.TransformationSpell.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.Controled && 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;
            }

            //bounty system
            if ( BountyBoard.Attackable( source, target ) )
                return Notoriety.CanBeAttacked;
            //end bounty system

            return Notoriety.Innocent;
        }
Example #24
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;
		}
Example #25
0
		public Item Mutate(Mobile from, int luckChance, Item item)
		{
			if (item != null)
			{
				if (item is BaseWeapon && 1 > Utility.Random(100))
				{
					item.Delete();
					item = new FireHorn();
					return item;
				}

				if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat)
				{
					if (Core.AOS)
					{
                        // Try to generate a new random item based on the creature killed
                        if (from is BaseCreature)
                        {
                            if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                                return item;
                        }

                        int bonusProps = GetBonusProperties();
						int min = m_MinIntensity;
						int max = m_MaxIntensity;

						if (bonusProps < m_MaxProps && LootPack.CheckLuck(luckChance))
						{
							++bonusProps;
						}

						int props = 1 + bonusProps;

						// Make sure we're not spawning items with 6 properties.
						if (props > m_MaxProps)
						{
							props = m_MaxProps;
						}

                        // Use the older style random generation
						if (item is BaseWeapon)
						{
							BaseRunicTool.ApplyAttributesTo((BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
						else if (item is BaseArmor)
						{
							BaseRunicTool.ApplyAttributesTo((BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
						else if (item is BaseJewel)
						{
							BaseRunicTool.ApplyAttributesTo((BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
						else if (item is BaseHat)
						{
							BaseRunicTool.ApplyAttributesTo((BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity);
						}
					}
					else // not aos
					{
						if (item is BaseWeapon)
						{
							BaseWeapon weapon = (BaseWeapon)item;

							if (80 > Utility.Random(100))
							{
								weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus();
							}

							if (60 > Utility.Random(100))
							{
								weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus();
							}

							if (40 > Utility.Random(100))
							{
								weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus();
							}

							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());
							}
						}
						else if (item is BaseArmor)
						{
							BaseArmor armor = (BaseArmor)item;

							if (80 > Utility.Random(100))
							{
								armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus();
							}

							if (40 > Utility.Random(100))
							{
								armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus();
							}
						}
					}
				}
				else if (item is BaseInstrument)
				{
					SlayerName slayer = SlayerName.None;

					if (Core.AOS)
					{
						slayer = BaseRunicTool.GetRandomSlayer();
					}
					else
					{
						slayer = SlayerGroup.GetLootSlayerType(from.GetType());
					}

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

					BaseInstrument instr = (BaseInstrument)item;

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

				if (item.Stackable)
				{
					item.Amount = m_Quantity.Roll();
				}
			}

			return item;
		}
Example #26
0
        public Item Mutate( Mobile from, int luckChance, Item item )
        {
            if ( item != null )
            {
                /*if ( item is BaseWeapon && 1 > Utility.Random( 100 ) ) //No FireHorns
                {
                    item.Delete();
                    item = new FireHorn();
                    return item;
                }*/

                if ( item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat )
                {
                    if ( Core.AOS )
                    {
                        int bonusProps = GetBonusProperties();
                        int min = m_MinIntensity;
                        int max = m_MaxIntensity;

                        if ( bonusProps < m_MaxProps && LootPack.CheckLuck( luckChance ) )
                            ++bonusProps;

                        int props = 1 + bonusProps;

                        // Make sure we're not spawning items with 6 properties.
                        if ( props > m_MaxProps )
                            props = m_MaxProps;

                        if ( item is BaseWeapon )
                            BaseRunicTool.ApplyAttributesTo( (BaseWeapon)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
                        else if ( item is BaseArmor )
                            BaseRunicTool.ApplyAttributesTo( (BaseArmor)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
                        else if ( item is BaseJewel )
                            BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
                        else if ( item is BaseHat )
                            BaseRunicTool.ApplyAttributesTo( (BaseHat)item, false, luckChance, props, m_MinIntensity, m_MaxIntensity );
                    }
                    else // not aos
                    {
                        if ( item is BaseWeapon )
                        {
                            BaseWeapon weapon = (BaseWeapon)item;

                            if ( 80 > Utility.Random( 100 ) )
                                weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus();

                            if ( 60 > Utility.Random( 100 ) )
                                weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus();

                            if ( 40 > Utility.Random( 100 ) )
                                weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus();

                            if ( 5 > Utility.Random( 100 ) )
                                weapon.Slayer = SlayerName.Silver;
                            //No slayer weapons
                            /*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() );*/
                        }
                        else if ( item is BaseArmor )
                        {
                            BaseArmor armor = (BaseArmor)item;

                            if ( 80 > Utility.Random( 100 ) )
                                armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus();

                            if ( 40 > Utility.Random( 100 ) )
                                armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus();
                        }
                    }
                }
                else if ( item is BaseInstrument )
                {
                    SlayerName slayer = SlayerName.None;

                    if ( Core.AOS )
                        slayer = BaseRunicTool.GetRandomSlayer();
                    else
                        slayer = SlayerGroup.GetLootSlayerType( from.GetType() );

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

                    BaseInstrument instr = (BaseInstrument)item;

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

                if ( item.Stackable )
                    item.Amount = m_Quantity.Roll();
            }

            return item;
        }
Example #27
0
        public override void Damage(int amount, Mobile from)
        {
            if (Spells.Necromancy.EvilOmenSpell.CheckEffect(this))
                amount = (int)(amount * 1.25);

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

            if (oath == this)
            {
                amount = (int)(amount * 1.1);
                from.Damage(amount, from);
            }

            #region GeNova: Mondain's Legacy
            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);
                }
            }
            #endregion

            base.Damage(amount, from);
        }
Example #28
0
		public bool Slays( Mobile m )
		{
			Type t = m.GetType();

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

			return false;
		}
Example #29
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;

			if( target.AccessLevel > AccessLevel.Player )
				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;

				master = bc.ControlMaster;

				if ( Core.ML && master != null )
				{
					if ( ( source == master && CheckAggressor( target.Aggressors, source ) ) || ( CheckAggressor( source.Aggressors, bc ) ) )
						return Notoriety.CanBeAttacked;
                    else if (bc is BaseEscortable || bc is BaseEscort)
                        return Notoriety.Innocent;
					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;

			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 )
					return Notoriety.CanBeAttacked;
			}

			return Notoriety.Innocent;
		}
		// 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;
		}