public static bool SkillGainAllowed( Mobile from, Skill skill )
		{
			if ( from.Player )
			{
				MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo( from );
				SkillRateInfo skillInfo = mobileInfo.GetSkillInfo( skill );

                // SKILL GAIN RESTRICTIONS
                // Here you can edit restrictions suitable for your needs 
				if ( skill.Base >= 100.0 && ( mobileInfo.SkillGainsCount >= 72 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes( 5.0 ) ) )
					return false;
				if ( skill.Base >= 90.0 && ( mobileInfo.SkillGainsCount >= 30 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes( 10.0 ) ) )
					return false;
				else if ( skill.Base >= 80.0 && ( mobileInfo.SkillGainsCount >= 60 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes( 5.0 ) ) )
					return false;
				else if ( skill.Base >= 70.0 && ( mobileInfo.SkillGainsCount >= 100 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes( 3.0 ) ) )
					return false;
				else if ( skill.Base < 70.0 )
					return true;
                // End!

				mobileInfo.SkillGainsCount++;

				skillInfo.LastGainTime = DateTime.Now;
				skillInfo.GainsCount++;
			}

			return true;
		}
		public static bool ForceSkillGain( Mobile from, Skill skill )
		{
			if ( from.Player )
			{
				MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo( from );
				SkillRateInfo skillInfo = mobileInfo.GetSkillInfo( skill );

				int[] table = null;

				if ( from.Skills.Total <= 350 )
					table = m_Terms350;
				else if ( from.Skills.Total <= 500 )
					table = m_Terms500;
				else
					table = m_Terms700;

                int index = skill.BaseFixedPoint / 50;

				if ( DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes( table[ index > 23 ? 23 : index ] ) )
					return false;

				return true;
			}

			return false;
		}
		public static void RegisterSkillGain( Mobile from, Skill skill )
		{
			if ( from.Player )
			{
				MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo( from );
				SkillRateInfo skillInfo = mobileInfo.GetSkillInfo( skill );

				skillInfo.LastGainTime = DateTime.Now;
			}
		}
 public bool Delete(Skill skill)
 {
     try
     {
         _ctx.Skills.Remove(skill);
         return true;
     }
     catch
     {
         return false;
     }
 }
 public bool Update(Skill oldSkill, Skill newSkill)
 {
     try
     {
         _ctx.Entry(oldSkill).CurrentValues.SetValues(newSkill);
         return true;
     }
     catch
     {
         return false;
     }
 }
 public bool Insert(Skill skill)
 {
     try
     {
         _ctx.Skills.Add(skill);
         return true;
     }
     catch
     {
         return false;
     }
 }
        // determines whether  XmlSpawner, XmlAttachment, or XmlQuest OnSkillUse methods should be invoked.
        public static void CheckSkillUse( Mobile m, Skill skill, bool success)
        {
            if(!(m is PlayerMobile) || skill == null) return;

            /*
            // first check for any attachments that might support OnSkillUse
            ArrayList list = XmlAttach.FindAttachments(m);
            if(list != null && list.Count > 0)
            {
                foreach(XmlAttachment a in list)
                {
                    if(a != null && !a.Deleted && a.HandlesOnSkillUse)
                    {
                        a.OnSkillUse(m, skill, success);
                    }
                }
            }
            */

            // then check for registered skills
            ArrayList skilllist = RegisteredSkill.TriggerList(skill.SkillName, m.Map);

            if(skilllist == null) return;

            // determine whether there are any registered objects for this skill
            foreach(RegisteredSkill rs in skilllist)
            {
                if(rs.sid == skill.SkillName)
                {
                    // if so then invoke their skill handlers
                    if(rs.target is XmlSpawner)
                    {
                        XmlSpawner spawner = (XmlSpawner)rs.target;

                        if ( spawner.HandlesOnSkillUse )
                        {
                            // call the spawner handler
                            spawner.OnSkillUse(m, skill, success);
                        }
                    } else
                    if(rs.target is IXmlQuest)
                    {
                        IXmlQuest quest = (IXmlQuest)rs.target;
                        if ( quest.HandlesOnSkillUse )
                        {
                           // call the xmlquest handler
                            quest.OnSkillUse(m, skill, success);
                        }
                    }
                }
            }
        }
Example #8
0
        public EditSkillGump( Mobile from, Mobile target, Skill skill, SkillsGumpGroup selected )
            : base(GumpOffsetX, GumpOffsetY)
        {
            m_From = from;
            m_Target = target;
            m_Skill = skill;
            m_Selected = selected;

            string initialText = m_Skill.Base.ToString( "F1" );

            AddPage( 0 );

            AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
            AddImageTiled( BorderSize, BorderSize, TotalWidth - ( OldStyle ? SetWidth + OffsetSize : 0 ), TotalHeight, OffsetGumpID );

            int x = BorderSize + OffsetSize;
            int y = BorderSize + OffsetSize;

            AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
            AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, skill.Name );
            x += EntryWidth + OffsetSize;

            if ( SetGumpID != 0 )
            {
                AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
            }

            x = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
            AddTextEntry( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, 0, initialText );
            x += EntryWidth + OffsetSize;

            if ( SetGumpID != 0 )
            {
                AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
            }

            AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
        }
Example #9
0
        public static bool eSkillTrabalho(Skill skill)
        {
            SkillName nomeSkill = skill.SkillName;

             	//Skills de trabalho
             	if(nomeSkill == SkillName.Alchemy
             	   || nomeSkill == SkillName.Blacksmith
             	   || nomeSkill == SkillName.Fletching
             	   || nomeSkill == SkillName.Carpentry
             	   || nomeSkill == SkillName.Cartography
             	   || nomeSkill == SkillName.Cooking
             	   || nomeSkill == SkillName.Fishing
             	   || nomeSkill == SkillName.Tailoring
             	   || nomeSkill == SkillName.Tinkering
             	   || nomeSkill == SkillName.Lumberjacking
             	   || nomeSkill == SkillName.Mining) {

             		return true;
             	}

             	return false;
        }
Example #10
0
        public Skills( Mobile owner, GenericReader reader )
        {
            m_Owner = owner;

            int version = reader.ReadInt();

            switch ( version )
            {
                case 3:
                case 2:
                {
                    m_Cap = reader.ReadInt();

                    goto case 1;
                }
                case 1:
                {
                    if ( version < 2 )
                        m_Cap = 7000;

                    if ( version < 3 )
                        /*m_Total =*/ reader.ReadInt();

                    SkillInfo[] info = SkillInfo.Table;

                    m_Skills = new Skill[info.Length];

                    int count = reader.ReadInt();

                    for ( int i = 0; i < count; ++i )
                    {
                        if ( i < info.Length )
                        {
                            Skill sk = new Skill( this, info[i], reader );

                            if ( sk.BaseFixedPoint != 0 || sk.CapFixedPoint != 1000 || sk.Lock != SkillLock.Up )
                            {
                                m_Skills[i] = sk;
                                m_Total += sk.BaseFixedPoint;
                            }
                        }
                        else
                        {
                            new Skill( this, null, reader );
                        }
                    }

                    //for ( int i = count; i < info.Length; ++i )
                    //	m_Skills[i] = new Skill( this, info[i], 0, 1000, SkillLock.Up );

                    break;
                }
                case 0:
                {
                    reader.ReadInt();

                    goto case 1;
                }
            }
        }
Example #11
0
 public static bool WillZero(this Skill skill, double value, bool isEqual = true)
 {
     return(isEqual ? (skill.Base - value <= 0) : (skill.Base - value < 0));
 }
Example #12
0
		private static bool AllowGain( Mobile from, Skill skill, object obj )
		{
			if ( Core.AOS && Faction.InSkillLoss( from ) )	//Changed some time between the introduction of AoS and SE.
				return false;

			if ( AntiMacroCode && from is PlayerMobile && UseAntiMacro[skill.Info.SkillID] )
				return ((PlayerMobile)from).AntiMacroCheck( skill, obj );
			else
				return true;
		}
Example #13
0
		public static void Gain( Mobile from, Skill skill )
		{
			if ( from.Region.IsPartOf( typeof( Regions.Jail ) ) )
				return;

			if ( from is BaseCreature && ((BaseCreature)from).IsDeadPet )
				return;

			if ( skill.SkillName == SkillName.Focus && from is BaseCreature )
				return;

			if ( skill.Base < skill.Cap && skill.Lock == SkillLock.Up )
			{
				int toGain = 1;

				if ( skill.Base <= 10.0 )
					toGain = Utility.Random( 4 ) + 1;

				Skills skills = from.Skills;

				if ( ( skills.Total / skills.Cap ) >= Utility.RandomDouble() )//( skills.Total >= skills.Cap )
				{


					for ( int i = 0; i < skills.Length; ++i )
					{
						Skill toLower = skills[i];

						if ( toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain )
						{
							toLower.BaseFixedPoint -= toGain;
							break;
						}
					}
				}			
				
				#region Mondain's Legacy
				if ( from is PlayerMobile )
					if ( Server.Engines.Quests.QuestHelper.EnhancedSkill( (PlayerMobile) from, skill ) )
						toGain *= Utility.RandomMinMax( 2, 4 );
				#endregion

				if ( (skills.Total + toGain) <= skills.Cap )
				{
					
				skill.BaseFixedPoint += toGain;
				}
				
				if(from is PlayerMobile)

				{
				PlayerMobile pm = (PlayerMobile)from;
				pm.SkillGainTimes[skill.SkillID] = DateTime.Now;
				} 
			}
				
			#region Mondain's Legacy
			if ( from is PlayerMobile )
				Server.Engines.Quests.QuestHelper.CheckSkill( (PlayerMobile) from, skill );
			#endregion

			if ( skill.Lock == SkillLock.Up )
			{
				SkillInfo info = skill.Info;

				if ( from.StrLock == StatLockType.Up && (info.StrGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Str );
				else if ( from.DexLock == StatLockType.Up && (info.DexGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Dex );
				else if ( from.IntLock == StatLockType.Up && (info.IntGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Int );

				else if ( from.StrLock == StatLockType.Up  )
					GainStat_GGS( from, Stat.Str );
				else if ( from.DexLock == StatLockType.Up )
					GainStat_GGS( from, Stat.Dex );
				else if ( from.IntLock == StatLockType.Up )
					GainStat_GGS( from, Stat.Int );
			}
			
		}
Example #14
0
		public static void Gain_GGS( Mobile from, Skill skill )
		{
			if ( !(from is PlayerMobile) ) 
				return;

			PlayerMobile pmob = (PlayerMobile)from;

			int ggCol;
			if(from.Skills.Total <= 3500)
				ggCol = 0;
			else if(from.Skills.Total <= 5000)
				ggCol = 1;
			else
				ggCol = 2;

			int ggRow = (int)(skill.Base / 5);
   
			if(ggRow < 0)
				ggRow = 0;
			else if(ggRow > 115/5)
				ggRow = 115/5;

			TimeSpan ggDelay = GGSTimes[ggRow,ggCol];

			Skills skills = from.Skills;

			object lgt = pmob.SkillGainTimes[skill.SkillID];

			if ( lgt == null || (DateTime)lgt + ggDelay < DateTime.Now ) 
			{
				Gain(from, skill);

				int hours = (int)ggDelay.TotalHours;

				if ( hours < 1 )
				{
					int minutes = (int)ggDelay.TotalMinutes;

					pmob.SendMessage("Narust skillu diky GGS!");
					pmob.SendMessage("Tva GGS pauza pro {0} je {1} Minutes", skill.SkillName.ToString(), minutes.ToString());	


				}
				else
				{
					pmob.SendMessage("Narust skillu diky GGS!");
					pmob.SendMessage("Tva GGS pauza pro {0} je {1} Hours", skill.SkillName.ToString(), hours.ToString());	
				}
			}
		}
Example #15
0
 public static bool IsLocked(this Skill skill, SkillLock locked)
 {
     return(skill.Lock == locked);
 }
Example #16
0
 public static bool IsZero(this Skill skill)
 {
     return(skill.Base <= 0);
 }
Example #17
0
 public static void IncreaseCap(this Skill skill, double value)
 {
     SetCap(skill, skill.Cap + value);
 }
Example #18
0
        public Skills(Mobile owner, GenericReader reader)
        {
            m_Owner = owner;

            int version = reader.ReadInt();

            switch (version)
            {
            case 3:
            case 2:
            {
                m_Cap = reader.ReadInt();

                goto case 1;
            }

            case 1:
            {
                if (version < 2)
                {
                    m_Cap = 7000;
                }

                if (version < 3)
                {
                    /*m_Total =*/
                    reader.ReadInt();
                }

                SkillInfo[] info = SkillInfo.Table;

                m_Skills = new Skill[info.Length];

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    if (i < info.Length)
                    {
                        Skill sk = new Skill(this, info[i], reader);

                        if (sk.BaseFixedPoint != 0 || sk.CapFixedPoint != 1000 || sk.Lock != SkillLock.Up)
                        {
                            m_Skills[i] = sk;
                            m_Total    += sk.BaseFixedPoint;
                        }
                    }
                    else
                    {
                        new Skill(this, null, reader);
                    }
                }

                //for ( int i = count; i < info.Length; ++i )
                //	m_Skills[i] = new Skill( this, info[i], 0, 1000, SkillLock.Up );

                break;
            }

            case 0:
            {
                reader.ReadInt();

                goto case 1;
            }
            }
        }
Example #19
0
 public static bool IsZeroOrCapped(this Skill skill)
 {
     return(IsZero(skill) || IsCapped(skill));
 }
 public bool CheckIfExist(Skill skill)
 {
     return _ctx.Skills.Any(skill1 => skill1.Name == skill.Name) ||
            _ctx.Skills.Find(skill.Id) != null;
 }
Example #21
0
		public void CheckTriggers( Mobile m, Skill s, bool hasproximity )
		{

			// only proximity trigger when no spawns have already been triggered
			if( AllowTriggering && !m_proximityActivated )
			{
				bool needs_item_trigger = false;
				bool needs_speech_trigger = false;
				bool needs_skill_trigger = false;
				bool needs_object_trigger = false;
				bool needs_mob_trigger = false;
				bool needs_player_trigger = false;
				bool needs_noitem_trigger = false;
				bool has_object_trigger = false;
				bool has_mob_trigger = false;
				bool has_player_trigger = false;
				bool has_item_trigger = false;
				bool has_noitem_trigger = true; // assume the player doesnt have the trigger-blocking item until it is found by search

				m_skipped = false;

				// test for the various triggering options in the order of increasing computational demand.  No point checking a high demand test
				// if a low demand one has already failed.

				// check for external triggering
				if( m_ExternalTriggering && !m_ExternalTrigger ) return;

				// if speech triggering is set then test for successful activation
				if( m_SpeechTrigger != null && m_SpeechTrigger.Length > 0 )
				{
					needs_speech_trigger = true;
				}
				// check to see if we have to continue
				if( needs_speech_trigger && !m_speechTriggerActivated ) return;

				// if skill triggering is set then test for successful activation
				if( m_SkillTrigger != null && m_SkillTrigger.Length > 0 )
				{
					needs_skill_trigger = true;
				}
				// check to see if we have to continue
				if( needs_skill_trigger && !m_skillTriggerActivated ) return;

				// if item property triggering is set then test for the property value
				//
				if( m_ObjectPropertyName != null && m_ObjectPropertyName.Length > 0 )
				{
					needs_object_trigger = true;
					string status_str;

					if( BaseXmlSpawner.TestItemProperty( this, m_ObjectPropertyItem, m_ObjectPropertyName, null, out status_str ) )
					{
						has_object_trigger = true;
					}
					else
						has_object_trigger = false;
					if( status_str != null && status_str.Length > 0 )
					{
						this.status_str = status_str;
					}
				}

				// check to see if we have to continue
				if( needs_object_trigger && !has_object_trigger ) return;

				// if player property triggering is set then look for the mob and test properties
				if( m_PlayerPropertyName != null && m_PlayerPropertyName.Length > 0 )
				{
					needs_player_trigger = true;
					string status_str;

					if( BaseXmlSpawner.TestMobProperty( this, m, m_PlayerPropertyName, null, out status_str ) )
					{
						has_player_trigger = true;
					}
					else
						has_player_trigger = false;
					if( status_str != null && status_str.Length > 0 )
					{
						this.status_str = status_str;
					}
				}

				// check to see if we have to continue
				if( needs_player_trigger && !has_player_trigger ) return;

				// if mob property triggering is set then look for the mob and test properties
				if( m_MobPropertyName != null && m_MobPropertyName.Length > 0 &&
					m_MobTriggerName != null && m_MobTriggerName.Length > 0 )
				{
					needs_mob_trigger = true;

					string status_str;

					if( BaseXmlSpawner.TestMobProperty( this, MobTriggerId, m_MobPropertyName, null, out status_str ) )
					{
						has_mob_trigger = true;
					}
					else
						has_mob_trigger = false;

					if( status_str != null && status_str.Length > 0 )
					{
						this.status_str = status_str;
					}
				}

				// check to see if we have to continue
				if( needs_mob_trigger && !has_mob_trigger ) return;

				// if player-carried item triggering is set then test for the presence of an item on the player an in their pack
				if( m_ItemTriggerName != null && m_ItemTriggerName.Length > 0 )
				{
					//enable_triggering = false;
					needs_item_trigger = true;

					has_item_trigger = BaseXmlSpawner.CheckForCarried( m, m_ItemTriggerName );
				}
				// check to see if we have to continue
				if( needs_item_trigger && !has_item_trigger ) return;

				// if player-carried noitem triggering is set then test for the presence of an item in the players pack that should block triggering
				if( m_NoItemTriggerName != null && m_NoItemTriggerName.Length > 0 )
				{
					needs_noitem_trigger = true;

					has_noitem_trigger = BaseXmlSpawner.CheckForNotCarried( m, m_NoItemTriggerName );
				}
				// check to see if we have to continue
				if( needs_noitem_trigger && !has_noitem_trigger ) return;

				// if this was called without being proximity triggered then check to see that the non-movement triggers were enabled.
				if( !hasproximity && !needs_object_trigger && !needs_mob_trigger && !m_ExternalTriggering ) return;

				// all of the necessary trigger conditions have been met so go ahead and trigger
				// after you make the probability check

				if( Utility.RandomDouble() < m_TriggerProbability )
				{

					// play a sound indicating the spawner has been triggered
					if( m_ProximityTriggerSound > 0 && m != null && !m.Deleted )
						m.PlaySound( m_ProximityTriggerSound );

					// display the trigger message
					if( m_ProximityTriggerMessage != null && m_ProximityTriggerMessage.Length > 0 && m != null && !m.Deleted )
						m.PublicOverheadMessage( MessageType.Regular, 0x3B2, true, m_ProximityTriggerMessage );

					// enable spawning at the next ontick
					// this will also start the refractory timer and send the triggering indicators
					ProximityActivated = true;

					// keep track of who triggered this
					m_mob_who_triggered = m;

					// keep track of the skill that triggered this
					if( s != null )
					{
						m_skill_that_triggered = s.SkillName;
					}
					else
					{
						m_skill_that_triggered = XmlSpawnerSkillCheck.RegisteredSkill.Invalid;
					}


				}
				else
				{
					m_skipped = true;
					// reset speech triggering if it was set

					m_speechTriggerActivated = false;

					// reset skill triggering if it was set
					m_skillTriggerActivated = false;
					// reset external triggering if it was set
					//this.m_ExternalTrigger = false;
				}
			}
		}
Example #22
0
		public virtual bool ValidateSkill(Mobile user, Skill skill, bool message)
		{
			if (user == null || user.Deleted || skill == null)
			{
				return false;
			}

			switch (Mode)
			{
				case SkillCodexMode.Increase:
				{
					if (Flags == SkillCodexFlags.Base || Flags == SkillCodexFlags.Both)
					{
						if (user.SkillsTotal + ValueFixed > user.SkillsCap)
						{
							if (!CanReduceSkills(user))
							{
								if (message)
								{
									user.SendMessage(
										SuperGump.DefaultErrorHue,
										"You already know everything this codex can offer, reduce some skills to make room for more knowledge.");
								}

								return false;
							}
						}

						if (skill.IsCapped() || skill.WillCap(Value, false))
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already know everything this codex can offer about {0}.",
									skill.Name);
							}

							return false;
						}

						if (!skill.IsLocked(SkillLock.Up))
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "The skill {0} is locked.", skill.Name);
							}

							return false;
						}
					}
				}
					break;
				case SkillCodexMode.Decrease:
				{
					if (Flags == SkillCodexFlags.Base || Flags == SkillCodexFlags.Both)
					{
						if (user.SkillsTotal - ValueFixed < 0)
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "You already forgot everything this codex can offer.");
							}

							return false;
						}

						if (skill.IsZero() || skill.WillZero(Value, false))
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already forgot everything this codex can offer about {0}, any further and you'll forget how to breath!",
									skill.Name);
							}

							return false;
						}

						if (!skill.IsLocked(SkillLock.Down))
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "The skill {0} is locked.", skill.Name);
							}

							return false;
						}
					}
				}
					break;
				case SkillCodexMode.Fixed:
				{
					if (Flags == SkillCodexFlags.Cap)
					{
						if (skill.CapFixedPoint == ValueFixed)
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already know everything this codex can offer about {0}.",
									skill.Name);
							}

							return false;
						}
					}

					if (Flags == SkillCodexFlags.Base || Flags == SkillCodexFlags.Both)
					{
						if (ValueFixed < skill.BaseFixedPoint)
						{
							if (user.SkillsTotal - (skill.BaseFixedPoint - ValueFixed) < 0)
							{
								if (message)
								{
									user.SendMessage(
										SuperGump.DefaultErrorHue,
										"You already forgot everything this codex can offer, any further and you'll forget how to breath!");
								}

								return false;
							}
						}
						else if (ValueFixed > skill.BaseFixedPoint)
						{
							if (user.SkillsTotal + (ValueFixed - skill.BaseFixedPoint) > user.SkillsCap)
							{
								if (!CanReduceSkills(user))
								{
									if (message)
									{
										user.SendMessage(
											SuperGump.DefaultErrorHue,
											"You already know everything this codex can offer, reduce some skills to make room for more knowledge.");
									}

									return false;
								}
							}
						}
						else
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already know everything this codex can offer about {0}.",
									skill.Name);
							}

							return false;
						}

						if (skill.IsLocked(SkillLock.Locked))
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "The skill {0} is locked.", skill.Name);
							}

							return false;
						}
					}
				}
					break;
			}

			return true;
		}
Example #23
0
 public static bool IsCapped(this Skill skill)
 {
     return(skill.Base >= skill.Cap);
 }
Example #24
0
        public bool AntiMacroCheck(Skill skill, object obj)
        {
            if (obj == null || m_AntiMacroTable == null || this.AccessLevel != AccessLevel.Player)
                return true;

            Hashtable tbl = (Hashtable)m_AntiMacroTable[skill];
            if (tbl == null)
                m_AntiMacroTable[skill] = tbl = new Hashtable();

            CountAndTimeStamp count = (CountAndTimeStamp)tbl[obj];
            if (count != null)
            {
                if (count.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.Now)
                {
                    count.Count = 1;
                    return true;
                }
                else
                {
                    ++count.Count;
                    if (count.Count <= SkillCheck.Allowance)
                        return true;
                    else
                        return false;
                }
            }
            else
            {
                tbl[obj] = count = new CountAndTimeStamp();
                count.Count = 1;

                return true;
            }
        }
		private bool IsRaceBonus( Mobile m, Skill skill ) {
			PlayerMobile pm = m as PlayerMobile;


			if( pm.Skills[skill.SkillID].Cap > 100.0 )
				return true;

			return false;
		}
Example #26
0
		// this is the handler for skill use
		public void OnSkillUse( Mobile m, Skill skill, bool success )
		{

			if( m_Running && m_ProximityRange >= 0 && ValidPlayerTrig( m ) && CanSpawn && !m_refractActivated && TODInRange )
			{

				if( !Utility.InRange( m.Location, this.Location, m_ProximityRange ) )
					return;

				m_skillTriggerActivated = false;

				// check the skill trigger conditions, Skillname[+/-][,min,max]
				if( m_SkillTrigger != null && (skill.SkillName == m_SkillTriggerName) &&
					((m_SkillTriggerMin < 0) || (skill.Value >= m_SkillTriggerMin)) &&
					((m_SkillTriggerMax < 0) || (skill.Value <= m_SkillTriggerMax)) &&
					((m_SkillTriggerSuccess == 3) || ((m_SkillTriggerSuccess == 1) && success) || ((m_SkillTriggerSuccess == 2) && !success)) )
				{
					// have a skill trigger so flag it and test it
					m_skillTriggerActivated = true;

					CheckTriggers( m, skill, true );
				}
			}
		}
Example #27
0
 public static void SetCap(this Skill skill, double value)
 {
     skill.Cap = Math.Max(0, value);
     Normalize(skill);
 }
Example #28
0
		protected void EndApply(Skill skill)
		{
			skill.Normalize();
			UseCharges();

			if (Count <= 0)
			{
				if (DeleteWhenEmpty)
				{
					Delete();
				}
			}
		}
Example #29
0
 public void OnSkillUse(Mobile m, Skill skill, bool success)
 {
 }
Example #30
0
 public override void OnSkillInvalidated(Skill skill)
 {
     if (Core.AOS && skill.SkillName == SkillName.MagicResist)
         UpdateResistances();
 }
		public static void Gain( Mobile from, Skill skill )
		{
			if ( from.Region.IsPartOf( typeof( Regions.Jail ) ) )
				return;

			if ( from is BaseCreature && ((BaseCreature)from).IsDeadPet )
				return;

			if ( skill.SkillName == SkillName.Focus && from is BaseCreature )
				return;

			if ( skill.Base < skill.Cap && skill.Lock == SkillLock.Up )
			{
				int toGain = 1;

				if ( skill.Base <= 10.0 )
					toGain = Utility.Random( 4 ) + 1;

				Skills skills = from.Skills;

				if ( from.Player && ( skills.Total / skills.Cap ) >= Utility.RandomDouble() )//( skills.Total >= skills.Cap )
				{
					for ( int i = 0; i < skills.Length; ++i )
					{
						Skill toLower = skills[i];

						if ( toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain )
						{
							toLower.BaseFixedPoint -= toGain;
							break;
						}
					}
				}

                #region Mondain's Legacy
                if (from is PlayerMobile)
                    if (Server.Engines.Quests.QuestHelper.EnhancedSkill((PlayerMobile)from, skill))
                        toGain *= Utility.RandomMinMax(2, 4);
                #endregion

				#region Scroll of Alacrity
				PlayerMobile pm = from as PlayerMobile;

				if ( from is PlayerMobile )
				{
					if ( pm != null && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.Now )
					{
						pm.SendLocalizedMessage(1077956); // You are infused with intense energy. You are under the effects of an accelerated skillgain scroll.
						toGain = Utility.RandomMinMax(2, 5);
					}
				}
                #endregion

				if ( !from.Player || (skills.Total + toGain) <= skills.Cap )
				{
					skill.BaseFixedPoint += toGain;
				}
			}

			#region Mondain's Legacy
			if ( from is PlayerMobile )
				Server.Engines.Quests.QuestHelper.CheckSkill( (PlayerMobile) from, skill );
			#endregion

			if ( skill.Lock == SkillLock.Up )
			{
				SkillInfo info = skill.Info;

				if ( from.StrLock == StatLockType.Up && (info.StrGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Str );
				else if ( from.DexLock == StatLockType.Up && (info.DexGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Dex );
				else if ( from.IntLock == StatLockType.Up && (info.IntGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Int );
			}
		}
Example #32
0
		public static bool CheckSkill( Mobile from, Skill skill, object amObj, double chance )
		{
			if ( from.Skills.Cap == 0 )
				return false;

			bool success = ( chance >= Utility.RandomDouble() );
			double gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;
			gc += ( skill.Cap - skill.Base ) / skill.Cap;
			gc /= 5;

			gc += ( 1.0 - chance ) * ( success ? 0.5 : (Core.AOS ? 0.0 : 0.2) );
			gc /= 5;

			gc *= skill.Info.GainFactor;

			if ( gc < 0.001 )
				gc = 0.001;

			if ( from is BaseCreature && ((BaseCreature)from).Controlled )
				gc *= 2;

			if ( from.Alive && ( ( gc >= Utility.RandomDouble() && AllowGain( from, skill, amObj ) ) || skill.Base < 10.0 ) )
				Gain( from, skill );

// GGS start
					else if ( chance <= 0.99 && chance >= 0.1 && skill.Base < skill.Cap && skill.Lock == SkillLock.Up ) 
					{
						if ( from.SkillsTotal >= from.SkillsCap )
						{
							for ( int i = 0; i < from.Skills.Length; ++i )
							{
								Skill sk = from.Skills[i];
	
								if ( sk.Base == 0 || sk.Lock != SkillLock.Down )
									continue;

								Gain_GGS( from, skill );
							}
						}
						else
							Gain_GGS( from, skill );
					}
// GGS end

			return success;
		}
Example #33
0
			public ConfirmSkillGump( SoulStone stone, Skill skill ) : base( 50, 50 )
			{
				m_Stone = stone;
				m_Skill = skill;

				AddBackground( 0, 0, 520, 440, 0x13BE );

				AddImageTiled( 10, 10, 500, 20, 0xA40 );
				AddImageTiled( 10, 40, 500, 360, 0xA40 );
				AddImageTiled( 10, 410, 500, 20, 0xA40 );

				AddAlphaRegion( 10, 10, 500, 420 );

				AddHtmlLocalized( 10, 12, 500, 20, 1070709, 0x7FFF, false, false ); // <CENTER>Confirm Soulstone Transfer</CENTER>

				/* <CENTER>Soulstone</CENTER><BR>
				 * You are using a Soulstone.  This powerful artifact allows you to remove skill points
				 * from your character and store them in the stone for later retrieval.  In order to use
				 * the stone, you must make sure your Skill Lock for the indicated skill is pointed downward.
				 * Click the "Skills" button on your Paperdoll to access the Skill List, and double-check
				 * your skill lock.<BR><BR>
				 * 
				 * Once you activate the stone, all skill points in the indicated skill will be removed from
				 * your character.  These skill points can later be retrieved.  IMPORTANT: When retrieving
				 * skill points from a Soulstone, the Soulstone WILL REPLACE any existing skill points
				 * already on your character!<BR><BR>
				 * 
				 * This is an Account Bound Soulstone.  Skill pointsstored inside can be retrieved by any
				 * character on the same account as the character who placed them into the stone.
				 */
				AddHtmlLocalized( 10, 42, 500, 110, 1061067, 0x7FFF, false, true );

				AddHtmlLocalized( 10, 200, 390, 20, 1062297, 0x7FFF, false, false ); // Skill Chosen:
                AddHtmlLocalized(210, 200, 390, 20, AosSkillBonuses.GetLabel(skill.SkillName), 0x7FFF, false, false);
 
				AddHtmlLocalized( 10, 220, 390, 20, 1062298, 0x7FFF, false, false ); // Current Value:
				AddLabel( 210, 220, 0x481, skill.Base.ToString( "0.0" ) );

				AddHtmlLocalized( 10, 240, 390, 20, 1062299, 0x7FFF, false, false ); // Current Cap:
				AddLabel( 210, 240, 0x481, skill.Cap.ToString( "0.0" ) );

				AddHtmlLocalized( 10, 260, 390, 20, 1062300, 0x7FFF, false, false ); // New Value:
				AddLabel( 210, 260, 0x481, "0.0" );

				AddButton( 10, 360, 0xFA5, 0xFA6, 2, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 45, 362, 450, 20, 1070720, 0x7FFF, false, false ); // Activate the stone.  I am ready to transfer the skill points to it.

				AddButton( 10, 380, 0xFA5, 0xFA6, 1, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 45, 382, 450, 20, 1062279, 0x7FFF, false, false ); // No, let me make another selection.

				AddButton( 10, 410, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 45, 412, 450, 20, 1060051, 0x7FFF, false, false ); // CANCEL
			}
Example #34
0
		private static bool AllowGain( Mobile from, Skill skill, object obj )
		{
			if ( AntiMacroCode && from is PlayerMobile && UseAntiMacro[skill.Info.SkillID] )
				return ((PlayerMobile)from).AntiMacroCheck( skill, obj );
			else
				return true;
		}
Example #35
0
        public Skill this[int skillID]
        {
            get
            {
                if ( skillID < 0 || skillID >= m_Skills.Length )
                    return null;

                Skill sk = m_Skills[skillID];

                if ( sk == null )
                    m_Skills[skillID] = sk = new Skill( this, SkillInfo.Table[skillID], 0, 1000, SkillLock.Up );

                return sk;
            }
        }
Example #36
0
        public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance)
        {
            if (from.Skills.Cap == 0)
                return false;

            bool success = (chance >= Utility.RandomDouble());
            double gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;
            gc += (skill.Cap - skill.Base) / skill.Cap;
            gc /= 2;

            gc += (1.0 - chance) * (success ? 0.5 : (Core.AOS ? 0.0 : 0.2));
            gc /= 2;

            gc *= skill.Info.GainFactor;

            if (gc < 0.01)
                gc = 0.01;

            if (from is BaseCreature && ((BaseCreature)from).Controlled)
                gc *= 2;

            if (from.Alive && ((gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj)) || skill.Base < 10.0))
                Gain(from, skill);

            return success;
        }/*
Example #37
0
        public void OnSkillChange( Skill skill )
        {
            if ( skill == m_Highest ) // could be downgrading the skill, force a recalc
                m_Highest = null;
            else if ( m_Highest != null && skill.BaseFixedPoint > m_Highest.BaseFixedPoint )
                m_Highest = skill;

            m_Owner.OnSkillInvalidated( skill );

            NetState ns = m_Owner.NetState;

            if ( ns != null )
                ns.Send( new SkillChange( skill ) );
        }
Example #38
0
		public static void Gain( Mobile from, Skill skill )
		{
			if ( from.Region.IsPartOf( typeof( Regions.Jail ) ) )
				return;

			if ( from is BaseCreature && ((BaseCreature)from).IsDeadPet )
				return;

			if ( skill.SkillName == SkillName.Focus && from is BaseCreature )
				return;

			if ( skill.Base < skill.Cap && skill.Lock == SkillLock.Up )
			{
				from.SendAsciiMessage("Gain!");
				int toGain = 1;

				if ( skill.Base <= 10.0 )
					toGain = Utility.Random( 4 ) + 1;

				Skills skills = from.Skills;

				if ( from.Player && ( skills.Total / skills.Cap ) >= Utility.RandomDouble() )//( skills.Total >= skills.Cap )
				{
					for ( int i = 0; i < skills.Length; ++i )
					{
						Skill toLower = skills[i];

						if ( toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain )
						{
							toLower.BaseFixedPoint -= toGain;
							break;
						}
					}
				}

				#region Scroll of Alacrity
				PlayerMobile pm = from as PlayerMobile;

				if ( from is PlayerMobile )
					if (pm != null && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.Now)
					toGain *= Utility.RandomMinMax(2, 5);
					#endregion

				if ( !from.Player || (skills.Total + toGain) <= skills.Cap )
				{
					skill.BaseFixedPoint += toGain;
				}
			}

			if ( skill.Lock == SkillLock.Up )
			{
				SkillInfo info = skill.Info;

				if ( from.StrLock == StatLockType.Up && (info.StrGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Str );
				else if ( from.DexLock == StatLockType.Up && (info.DexGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Dex );
				else if ( from.IntLock == StatLockType.Up && (info.IntGain / 33.3) > Utility.RandomDouble() )
					GainStat( from, Stat.Int );
			}
		}
Example #39
0
 public static bool WillCap(this Skill skill, double value, bool isEqual = true)
 {
     return(isEqual ? (skill.Base + value >= skill.Cap) : (skill.Base + value > skill.Cap));
 }