예제 #1
0
        public BaseCreature(AIType ai,
			FightMode mode,
			int iRangePerception,
			int iRangeFight,
			double dActiveSpeed, 
			double dPassiveSpeed)
        {
            if ( iRangePerception == OldRangePerception )
                iRangePerception = DefaultRangePerception;

            m_Loyalty = PetLoyalty.WonderfullyHappy;

            m_CurrentAI = ai;
            m_DefaultAI = ai;

            m_iRangePerception = iRangePerception;
            m_iRangeFight = iRangeFight;

            m_FightMode = mode;

            m_iTeam = 0;

            SpeedInfo.GetSpeeds( this, ref dActiveSpeed, ref dPassiveSpeed );

            m_dActiveSpeed = dActiveSpeed;
            m_dPassiveSpeed = dPassiveSpeed;
            m_dCurrentSpeed = dPassiveSpeed;

            m_bDebugAI = false;

            m_arSpellAttack = new ArrayList();
            m_arSpellDefense = new ArrayList();

            m_bControled = false;
            m_ControlMaster = null;
            m_ControlTarget = null;
            m_ControlOrder = OrderType.None;

            m_bTamable = false;

            m_Owners = new ArrayList();

            m_NextReaquireTime = DateTime.Now + ReaquireDelay;

            ChangeAIType(AI);

            InhumanSpeech speechType = this.SpeechType;

            if ( speechType != null )
                speechType.OnConstruct( this );

            GenerateLoot( true );
        }
예제 #2
0
        public BaseCreature( AIType ai,
            FightMode mode,
            int iRangePerception,
            int iRangeFight,
            double dActiveSpeed,
            double dPassiveSpeed)
        {
            if ( iRangePerception == OldRangePerception )
                iRangePerception = DefaultRangePerception;

            m_Loyalty = PetLoyalty.WonderfullyHappy;

            m_CurrentAI = ai;
            m_DefaultAI = ai;

            m_iRangePerception = iRangePerception;
            m_iRangeFight = iRangeFight;

            m_FightMode = mode;

            m_iTeam = 0;

            SpeedInfo.GetSpeeds( this, ref dActiveSpeed, ref dPassiveSpeed );

            m_dActiveSpeed = dActiveSpeed;
            m_dPassiveSpeed = dPassiveSpeed;
            m_dCurrentSpeed = dPassiveSpeed;

            m_bDebugAI = false;

            m_bControlled = false;
            m_ControlMaster = null;
            m_ControlTarget = null;
            m_ControlOrder = OrderType.None;

            m_bTamable = false;

            m_Owners = new List<Mobile>();

            m_NextReacquireTime = DateTime.Now + ReacquireDelay;

            ChangeAIType( AI );

            InhumanSpeech speechType = this.SpeechType;

            if ( speechType != null )
                speechType.OnConstruct( this );

            GenerateLoot( true );

            Timer.DelayCall( TimeSpan.FromSeconds( 0.01 ), new TimerCallback( CheckParagon ) );
        }
예제 #3
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            m_CurrentAI = (AIType)reader.ReadInt();
            m_DefaultAI = (AIType)reader.ReadInt();

            m_iRangePerception = reader.ReadInt();
            m_iRangeFight = reader.ReadInt();

            m_iTeam = reader.ReadInt();

            m_dActiveSpeed = reader.ReadDouble();
            m_dPassiveSpeed = reader.ReadDouble();
            m_dCurrentSpeed = reader.ReadDouble();

            double activeSpeed = m_dActiveSpeed;
            double passiveSpeed = m_dPassiveSpeed;

            SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );

            bool isStandardActive = false;
            for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
                isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );

            bool isStandardPassive = false;
            for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
                isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );

            if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
                m_dCurrentSpeed = activeSpeed;
            else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
                m_dCurrentSpeed = passiveSpeed;

            if ( isStandardActive )
                m_dActiveSpeed = activeSpeed;

            if ( isStandardPassive )
                m_dPassiveSpeed = passiveSpeed;

            if ( m_iRangePerception == OldRangePerception )
                m_iRangePerception = DefaultRangePerception;

            m_pHome.X = reader.ReadInt();
            m_pHome.Y = reader.ReadInt();
            m_pHome.Z = reader.ReadInt();

            if ( version >= 1 )
            {
                m_iRangeHome = reader.ReadInt();

                int i, iCount;

                iCount = reader.ReadInt();
                for ( i=0; i< iCount; i++ )
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType( str );

                    if ( type != null )
                    {
                        m_arSpellAttack.Add( type );
                    }
                }

                iCount = reader.ReadInt();
                for ( i=0; i< iCount; i++ )
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType( str );

                    if ( type != null )
                    {
                        m_arSpellDefense.Add( type );
                    }
                }
            }
            else
            {
                m_iRangeHome = 0;
            }

            if ( version >= 2 )
            {
                m_FightMode = ( FightMode )reader.ReadInt();

                m_bControled = reader.ReadBool();
                m_ControlMaster = reader.ReadMobile();
                m_ControlTarget = reader.ReadMobile();
                m_ControlDest = reader.ReadPoint3D();
                m_ControlOrder = (OrderType) reader.ReadInt();

                m_dMinTameSkill = reader.ReadDouble();

                if ( version < 9 )
                    reader.ReadDouble();

                m_bTamable = reader.ReadBool();
                m_bSummoned = reader.ReadBool();

                if ( m_bSummoned )
                {
                    m_SummonEnd = reader.ReadDeltaTime();
                    new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
                }

                m_iControlSlots = reader.ReadInt();
            }
            else
            {
                m_FightMode = FightMode.Closest;

                m_bControled = false;
                m_ControlMaster = null;
                m_ControlTarget = null;
                m_ControlOrder = OrderType.None;
            }

            if ( version >= 3 )
                m_Loyalty = (PetLoyalty)reader.ReadInt();
            else
                m_Loyalty = PetLoyalty.WonderfullyHappy;

            if ( version >= 4 )
                m_CurrentWayPoint = reader.ReadItem() as WayPoint;

            if ( version >= 5 )
                m_SummonMaster = reader.ReadMobile();

            if ( version >= 6 )
            {
                m_HitsMax = reader.ReadInt();
                m_StamMax = reader.ReadInt();
                m_ManaMax = reader.ReadInt();
                m_DamageMin = reader.ReadInt();
                m_DamageMax = reader.ReadInt();
            }

            if ( version >= 7 )
            {
                m_PhysicalResistance = reader.ReadInt();
                m_PhysicalDamage = reader.ReadInt();

                m_FireResistance = reader.ReadInt();
                m_FireDamage = reader.ReadInt();

                m_ColdResistance = reader.ReadInt();
                m_ColdDamage = reader.ReadInt();

                m_PoisonResistance = reader.ReadInt();
                m_PoisonDamage = reader.ReadInt();

                m_EnergyResistance = reader.ReadInt();
                m_EnergyDamage = reader.ReadInt();
            }

            if ( version >= 8 )
                m_Owners = reader.ReadMobileList();
            else
                m_Owners = new ArrayList();

            if ( version >= 10 )
            {
                m_IsDeadPet = reader.ReadBool();
                m_IsBonded = reader.ReadBool();
                m_BondingBegin = reader.ReadDateTime();
                m_OwnerAbandonTime = reader.ReadDateTime();
            }

            if ( version >= 11 )
                m_HasGeneratedLoot = reader.ReadBool();
            else
                m_HasGeneratedLoot = true;

                // temporary mod for conversion
                //reader.ReadTimeSpan();
                //m_Paragon = reader.ReadBool();

            if ( version >= 12 )
                m_Paragon = reader.ReadBool();
            else
                m_Paragon = false;

            if ( version >= 13 && reader.ReadBool() )
                m_Friends = reader.ReadMobileList();
            else if ( version < 13 && m_ControlOrder >= OrderType.Unfriend )
                ++m_ControlOrder;

            CheckStatTimers();

            ChangeAIType(m_CurrentAI);

            // ARTEGORDONMOD
            // PlayerRangeSensitiveMod
            if ( version >= 14 )
            {
                TimeSpan restartDeactivationdelay = reader.ReadTimeSpan();
                if(m_AI != null) {
                    m_AI.m_RestartDeactivationdelay = restartDeactivationdelay;
                }
            }

            if ( m_IsBonded == true )
                m_IsBonded = false;

            AddFollowers();

            if ( IsAnimatedDead )
                Spells.Necromancy.AnimateDeadSpell.Register( m_SummonMaster, this );
        }
예제 #4
0
        public virtual bool CheckFeed( Mobile from, Item dropped )
        {
            if ( !IsDeadPet && Controlled && ( ControlMaster == from || IsPetFriend( from ) ) && ( dropped is Food || dropped is Gold || dropped is CookableFood || dropped is Head || dropped is LeftArm || dropped is LeftLeg || dropped is Torso || dropped is RightArm || dropped is RightLeg || dropped is IPetBooster ) )
            {
                Item f = dropped;

                if ( dropped is IPetBooster )
                {
                    IPetBooster pb = dropped as IPetBooster;

                    return pb.OnUsed( from, this );
                }
                else if ( CheckFoodPreference( f ) )
                {
                    int amount = f.Amount;

                    if ( amount > 0 )
                    {
                        bool happier = false;

                        int stamGain;

                        if ( f is Gold )
                            stamGain = amount - 50;
                        else
                            stamGain = ( amount * 15 ) - 50;

                        if ( stamGain > 0 )
                            Stam += stamGain;

                        if ( m_Loyalty != PetLoyalty.WonderfullyHappy )
                        {
                            m_Loyalty = PetLoyalty.WonderfullyHappy;
                            happier = true;
                        }

                        #region PetBondingGate
                        if ( TestCenter.Enabled )
                        {
                            if ( !IsBonded )
                            {
                                var overPetBondingGate = from.GetItemsInRange( 5 ).OfType<PetBondingGate>()
                                    .Any( pbg => pbg.Location == from.Location && pbg.Location == Location );

                                if ( overPetBondingGate )
                                {
                                    IsBonded = true;
                                    BondingBegin = DateTime.MinValue;
                                    from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
                                }
                            }
                        }
                        #endregion

                        if ( happier )
                            SayTo( from, 502060 ); // Your pet looks happier.

                        if ( Body.IsAnimal )
                            Animate( 3, 5, 1, true, false, 0 );
                        else if ( Body.IsMonster )
                            Animate( 17, 5, 1, true, false, 0 );

                        if ( IsBondable && !IsBonded )
                        {
                            Mobile master = m_ControlMaster;

                            if ( master != null && master == from )	//So friends can't start the bonding process
                            {
                                if ( m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Base >= m_dMinTameSkill || this is SwampDragon || this is Ridgeback || this is SavageRidgeback || this is FireBeetle || this is LesserHiryu || this is IronBeetle )
                                {
                                    if ( BondingBegin == DateTime.MinValue )
                                    {
                                        BondingBegin = DateTime.Now;
                                    }
                                    else if ( ( BondingBegin + BondingDelay ) <= DateTime.Now )
                                    {
                                        IsBonded = true;
                                        BondingBegin = DateTime.MinValue;
                                        from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
                                    }
                                }
                                else
                                {
                                    from.SendLocalizedMessage( 1075268 ); // Your pet cannot form a bond with you until your animal taming ability has risen.
                                }
                            }
                        }

                        dropped.Delete();
                        return true;
                    }
                }
                else if ( !( dropped is Gold ) )
                {
                    SayTo( from, 1043257 ); // The animal shies away.
                }
            }

            return false;
        }
예제 #5
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            if ( version >= 16 && version <= 18 )
                reader.ReadItem(); // spawner

            m_CurrentAI = (AIType) reader.ReadInt();
            m_DefaultAI = (AIType) reader.ReadInt();

            m_iRangePerception = reader.ReadInt();
            m_iRangeFight = reader.ReadInt();

            m_iTeam = reader.ReadInt();

            m_dActiveSpeed = reader.ReadDouble();
            m_dPassiveSpeed = reader.ReadDouble();
            m_dCurrentSpeed = reader.ReadDouble();

            double activeSpeed = m_dActiveSpeed;
            double passiveSpeed = m_dPassiveSpeed;

            SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );

            bool isStandardActive = false;
            for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
            {
                isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );
            }

            bool isStandardPassive = false;
            for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
            {
                isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );
            }

            if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
            {
                m_dCurrentSpeed = activeSpeed;
            }
            else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
            {
                m_dCurrentSpeed = passiveSpeed;
            }

            if ( isStandardActive )
            {
                m_dActiveSpeed = activeSpeed;
            }

            if ( isStandardPassive )
            {
                m_dPassiveSpeed = passiveSpeed;
            }

            if ( m_iRangePerception == OldRangePerception )
            {
                m_iRangePerception = DefaultRangePerception;
            }

            m_pHome.X = reader.ReadInt();
            m_pHome.Y = reader.ReadInt();
            m_pHome.Z = reader.ReadInt();

            if ( version >= 1 )
            {
                m_iRangeHome = reader.ReadInt();

                if ( version < 25 )
                {
                    int i, iCount;

                    iCount = reader.ReadInt();
                    for ( i = 0; i < iCount; i++ )
                        reader.ReadString();

                    iCount = reader.ReadInt();
                    for ( i = 0; i < iCount; i++ )
                        reader.ReadString();
                }
            }
            else
            {
                m_iRangeHome = 0;
            }

            if ( version >= 2 )
            {
                m_FightMode = (FightMode) reader.ReadInt();

                m_bControlled = reader.ReadBool();
                m_ControlMaster = reader.ReadMobile();
                m_ControlTarget = reader.ReadMobile();
                m_ControlDest = reader.ReadPoint3D();
                m_ControlOrder = (OrderType) reader.ReadInt();

                m_dMinTameSkill = reader.ReadDouble();

                if ( version < 9 )
                    reader.ReadDouble();

                m_bTamable = reader.ReadBool();
                m_bSummoned = reader.ReadBool();

                if ( m_bSummoned )
                {
                    m_SummonEnd = reader.ReadDeltaTime();
                    new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
                }

                m_iControlSlots = reader.ReadInt();
            }
            else
            {
                m_FightMode = FightMode.Closest;

                m_bControlled = false;
                m_ControlMaster = null;
                m_ControlTarget = null;
                m_ControlOrder = OrderType.None;
            }

            if ( version >= 3 )
                m_Loyalty = (PetLoyalty) reader.ReadInt();
            else
                m_Loyalty = PetLoyalty.WonderfullyHappy;

            if ( version >= 4 )
                m_CurrentWayPoint = reader.ReadItem() as WayPoint;

            if ( version >= 5 )
                m_SummonMaster = reader.ReadMobile();

            if ( version >= 6 )
            {
                m_HitsMax = reader.ReadInt();
                m_StamMax = reader.ReadInt();
                m_ManaMax = reader.ReadInt();
                m_DamageMin = reader.ReadInt();
                m_DamageMax = reader.ReadInt();
            }

            if ( version >= 7 )
            {
                m_PhysicalResistance = reader.ReadInt();
                m_PhysicalDamage = reader.ReadInt();

                m_FireResistance = reader.ReadInt();
                m_FireDamage = reader.ReadInt();

                m_ColdResistance = reader.ReadInt();
                m_ColdDamage = reader.ReadInt();

                m_PoisonResistance = reader.ReadInt();
                m_PoisonDamage = reader.ReadInt();

                m_EnergyResistance = reader.ReadInt();
                m_EnergyDamage = reader.ReadInt();
            }

            if ( version >= 8 )
                m_Owners = reader.ReadStrongMobileList();
            else
                m_Owners = new List<Mobile>();

            if ( version >= 10 )
            {
                m_IsDeadPet = reader.ReadBool();
                m_IsBonded = reader.ReadBool();
                m_BondingBegin = reader.ReadDateTime();
                m_OwnerAbandonTime = reader.ReadDateTime();
            }

            if ( version >= 11 )
                m_HasGeneratedLoot = reader.ReadBool();
            else
                m_HasGeneratedLoot = true;

            if ( version >= 12 )
            {
                m_Paragon = reader.ReadBool();
                m_IsChampionMonster = reader.ReadBool();
            }
            else
            {
                m_Paragon = false;
                m_IsChampionMonster = false;
            }

            if ( version >= 13 && reader.ReadBool() )
                m_Friends = reader.ReadStrongMobileList();
            else if ( version < 13 && m_ControlOrder >= OrderType.Unfriend )
                ++m_ControlOrder;

            if ( version >= 14 )
                m_SpawnLevel = reader.ReadInt();
            else
                m_SpawnLevel = 0;

            if ( version >= 15 )
                m_ChampionType = (ChampionSpawnType) reader.ReadInt();

            if ( version >= 17 )
                m_StolenFrom = reader.ReadBool();

            if ( version >= 18 )
            {
                int count = reader.ReadInt();

                for ( int i = 0; i < count; i++ )
                {
                    Item rummaged = reader.ReadItem();
                    Mobile owner = reader.ReadMobile();

                    if ( rummaged != null && owner != null )
                        m_RummagedItems.Add( rummaged, owner );
                }
            }

            if ( version >= 20 )
            {
                m_IsMinichampMonster = reader.ReadBool();
                m_MinichampType = (MiniChampType) reader.ReadInt();
            }

            if ( version >= 21 )
            {
                m_NextTastyTreat = reader.ReadDateTime();
            }

            if ( version >= 22 )
            {
                m_Petrified = reader.ReadBool();

                if ( m_Petrified )
                {
                    m_StatueAnimation = reader.ReadInt();
                    m_StatueFrames = reader.ReadInt();

                    Frozen = true;
                    HueMod = 2401;
                }
            }

            if ( version >= 23 )
            {
                m_NextArmorEssence = reader.ReadDateTime();
            }

            if ( version >= 24 )
            {
                m_IsGolem = reader.ReadBool();
            }
            else
            {
                m_IsGolem = this is Golem;
            }

            CheckStatTimers();

            ChangeAIType( m_CurrentAI );

            AddFollowers();

            if ( IsAnimatedDead )
                Spells.Necromancy.AnimateDeadSpell.Register( m_SummonMaster, this );

            if ( Controlled )
                Skills.Cap = 15000;
        }
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			m_CurrentAI = (AIType)reader.ReadInt();
			m_DefaultAI = (AIType)reader.ReadInt();

			m_iRangePerception = reader.ReadInt();
			m_iRangeFight = reader.ReadInt();

			m_iTeam = reader.ReadInt();

			m_dActiveSpeed = reader.ReadDouble();
			m_dPassiveSpeed = reader.ReadDouble();
			m_dCurrentSpeed = reader.ReadDouble();

			double activeSpeed = m_dActiveSpeed;
			double passiveSpeed = m_dPassiveSpeed;

			SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );

			bool isStandardActive = false;
			for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
				isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );

			bool isStandardPassive = false;
			for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
				isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );

			if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
				m_dCurrentSpeed = activeSpeed;
			else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
				m_dCurrentSpeed = passiveSpeed;

			if ( isStandardActive )
				m_dActiveSpeed = activeSpeed;

			if ( isStandardPassive )
				m_dPassiveSpeed = passiveSpeed;

			if ( m_iRangePerception == OldRangePerception )
				m_iRangePerception = DefaultRangePerception;

			m_pHome.X = reader.ReadInt();
			m_pHome.Y = reader.ReadInt();
			m_pHome.Z = reader.ReadInt();

			if ( version >= 1 )
			{
				m_iRangeHome = reader.ReadInt();
                m_arSpellAttack = ReadTypeArray(reader);
                m_arSpellDefense = ReadTypeArray(reader);
			}
			else
			{
				m_iRangeHome = 0;
			}

			if ( version >= 2 )
			{
				m_FightMode = ( FightMode )reader.ReadInt();

				m_bControlled = reader.ReadBool();
				m_ControlMaster = reader.ReadMobile();
				m_ControlTarget = reader.ReadMobile();
				m_ControlDest = reader.ReadPoint3D();
				m_ControlOrder = (OrderType) reader.ReadInt();

				m_dMinTameSkill = reader.ReadDouble();

				if ( version < 9 )
					reader.ReadDouble();

				m_bTamable = reader.ReadBool();
				m_bSummoned = reader.ReadBool();

				if ( m_bSummoned )
				{
					m_SummonEnd = reader.ReadDeltaTime();
					new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
				}

				m_iControlSlots = reader.ReadInt();
			}
			else
			{
				m_FightMode = FightMode.Closest;

				m_bControlled = false;
				m_ControlMaster = null;
				m_ControlTarget = null;
				m_ControlOrder = OrderType.None;
			}

			if ( version >= 3 )
				m_Loyalty = (PetLoyalty)reader.ReadInt();
			else
				m_Loyalty = PetLoyalty.WonderfullyHappy;

			if ( version >= 4 )
				m_CurrentWayPoint = reader.ReadItem() as WayPoint;

			if ( version >= 5 )
				m_SummonMaster = reader.ReadMobile();

			if ( version >= 6 )
			{
				m_HitsMax = reader.ReadInt();
				m_StamMax = reader.ReadInt();
				m_ManaMax = reader.ReadInt();
				m_DamageMin = reader.ReadInt();
				m_DamageMax = reader.ReadInt();
			}

			if ( version >= 7 )
			{
				m_PhysicalResistance = reader.ReadInt();
				m_PhysicalDamage = reader.ReadInt();

				m_FireResistance = reader.ReadInt();
				m_FireDamage = reader.ReadInt();

				m_ColdResistance = reader.ReadInt();
				m_ColdDamage = reader.ReadInt();

				m_PoisonResistance = reader.ReadInt();
				m_PoisonDamage = reader.ReadInt();

				m_EnergyResistance = reader.ReadInt();
				m_EnergyDamage = reader.ReadInt();
			}

			if (version >= 8)
			{
				m_Owners = reader.ReadMobileList();
				if (m_Owners.Count == 0) m_Owners = null;
			}

			if ( version >= 10 )
			{
				m_IsDeadPet = reader.ReadBool();
				m_IsBonded = reader.ReadBool();
				m_BondingBegin = reader.ReadDateTime();
				m_OwnerAbandonTime = reader.ReadDateTime();
			}

			if ( version >= 11 )
				m_HasGeneratedLoot = reader.ReadBool();
			else
				m_HasGeneratedLoot = true;

			if ( version >= 12 )
				m_Paragon = reader.ReadBool();
			else
				m_Paragon = false;

			if ( version >= 13 && reader.ReadBool() )
				m_Friends = reader.ReadMobileList();
			else if ( version < 13 && m_ControlOrder >= OrderType.Unfriend )
				++m_ControlOrder;

			if ( version >= 14 )
			{
				m_RemoveIfUntamed = reader.ReadBool();
				m_RemoveStep = reader.ReadInt();
			}

// *** Added for Valor ***
			if ( version >= 14 )
			{
				m_IsChampionMonster = reader.ReadBool();
				m_SpawnLevel = reader.ReadInt();
			}
// *** ***

			CheckStatTimers();

			ChangeAIType(m_CurrentAI);

			AddFollowers();

			if ( IsAnimatedDead )
				Spells.Necromancy.AnimateDeadSpell.Register( m_SummonMaster, this );
		}
예제 #7
0
		public virtual bool CheckFeed( Mobile from, Item dropped )
		{
			if ( !IsDeadPet && Controlled && ControlMaster == from && (dropped is Food || dropped is Gold || dropped is CookableFood || dropped is Head || dropped is LeftArm || dropped is LeftLeg || dropped is Torso || dropped is RightArm || dropped is RightLeg || dropped is KukuiNut) )
			{
				Item f = dropped;

				if ( CheckFoodPreference( f ) )
				{
					int amount = f.Amount;

					if ( amount > 0 )
					{
						bool happier = false;

						int stamGain;

						if ( f is Gold )
							stamGain = amount - 50;
						else
							stamGain = (amount * 15) - 50;

						if ( stamGain > 0 )
							Stam += stamGain;

						for ( int i = 0; i < amount; ++i )
						{	// adam: make sure feeding always resets the LoyaltyCheck
							if ( 0.5 >= Utility.RandomDouble() )
							{
								bool bump = (int)m_Loyalty < MaxLoyalty; // loyalty redo
								if ( bump )
									m_Loyalty += Utility.RandomMinMax(7, 13); // loyalty redo

								// if there was a bump in loyalty or the pet has not been feed in 5 minutes
								if ( bump || DateTime.Now - LoyaltyCheck > TimeSpan.FromMinutes( 5 ))
								{
									happier = true;
									LoyaltyCheck = DateTime.Now + TimeSpan.FromHours( 1.0 );
								}
								else
									DebugSay("I'm not hungry");
							}
						}

						if ( happier )
							SayTo( from, 502060 ); // Your pet looks happier.

						if ( Body.IsAnimal )
							Animate( 3, 5, 1, true, false, 0 );
						else if ( Body.IsMonster )
							Animate( 17, 5, 1, true, false, 0 );

						if ( IsBondable && !IsBonded )
						{
							Mobile master = m_ControlMaster;

							if ( master != null )
							{
								if ( m_dMinTameSkill <= 29.1 || master.Skills[SkillName.AnimalTaming].Value >= m_dMinTameSkill || this is SwampDragon || this is Ridgeback || this is SavageRidgeback )
								{
									if ( BondingBegin == DateTime.MinValue )
									{
										BondingBegin = DateTime.Now;
									}
									else if ( (BondingBegin + BondingDelay) <= DateTime.Now )
									{
										IsBonded = true;
										BondingBegin = DateTime.MinValue;
										from.SendLocalizedMessage( 1049666 ); // Your pet has bonded with you!
									}
								}
							}
						}

						dropped.Delete();
						return true;
					}
				}
			}

			return false;
		}
예제 #8
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			m_CurrentAI = (AIType)reader.ReadInt();
			m_DefaultAI = (AIType)reader.ReadInt();

			m_iRangePerception = reader.ReadInt();
			m_iRangeFight = reader.ReadInt();

			m_iTeam = reader.ReadInt();

			m_dActiveSpeed = reader.ReadDouble();
			m_dPassiveSpeed = reader.ReadDouble();
			m_dCurrentSpeed = reader.ReadDouble();

			double activeSpeed = m_dActiveSpeed;
			double passiveSpeed = m_dPassiveSpeed;

			//			SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );

			bool isStandardActive = false;
			for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
				isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );

			bool isStandardPassive = false;
			for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
				isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );

			if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
				m_dCurrentSpeed = activeSpeed;
			else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
				m_dCurrentSpeed = passiveSpeed;

			if ( isStandardActive )
				m_dActiveSpeed = activeSpeed;

			if ( isStandardPassive )
				m_dPassiveSpeed = passiveSpeed;

			if ( m_iRangePerception == OldRangePerception )
				m_iRangePerception = DefaultRangePerception;

			m_pHome.X = reader.ReadInt();
			m_pHome.Y = reader.ReadInt();
			m_pHome.Z = reader.ReadInt();

			if ( version >= 1 )
			{
				m_iRangeHome = reader.ReadInt();

				int i, iCount;

				iCount = reader.ReadInt();
				for ( i=0; i< iCount; i++ )
				{
					string str = reader.ReadString();
					Type type = Type.GetType( str );

					if ( type != null )
					{
						m_arSpellAttack.Add( type );
					}
				}

				iCount = reader.ReadInt();
				for ( i=0; i< iCount; i++ )
				{
					string str = reader.ReadString();
					Type type = Type.GetType( str );

					if ( type != null )
					{
						m_arSpellDefense.Add( type );
					}
				}
			}
			else
			{
				m_iRangeHome = 0;
			}

			if ( version >= 2 )
			{
				m_FightMode = ( FightMode )reader.ReadInt();

				m_bControled = reader.ReadBool();
				m_ControlMaster = reader.ReadMobile();
				m_ControlTarget = reader.ReadMobile();
				m_ControlDest = reader.ReadPoint3D();
				m_ControlOrder = (OrderType) reader.ReadInt();

				m_dMinTameSkill = reader.ReadDouble();

				if ( version < 9 )
					reader.ReadDouble();

				m_bTamable = reader.ReadBool();
				m_bSummoned = reader.ReadBool();

				if ( m_bSummoned )
				{
					m_SummonEnd = reader.ReadDeltaTime();
					new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
				}

				m_iControlSlots = reader.ReadInt();
			}
			else
			{
				m_FightMode = FightMode.All | FightMode.Closest;

				m_bControled = false;
				m_ControlMaster = null;
				m_ControlTarget = null;
				m_ControlOrder = OrderType.None;
			}

			if ( version >= 3 ) // loyalty redo
			{
				m_Loyalty = (PetLoyalty)reader.ReadInt();

				if (version < 23)
					m_Loyalty = (PetLoyalty)((int)m_Loyalty * 10);
			}
			else
				m_Loyalty = PetLoyalty.WonderfullyHappy;


			if ( version >= 4 )
				m_CurrentWayPoint = reader.ReadItem() as WayPoint;

			if ( version >= 5 )
				m_SummonMaster = reader.ReadMobile();

			if ( version >= 6 )
			{
				m_HitsMax = reader.ReadInt();
				m_StamMax = reader.ReadInt();
				m_ManaMax = reader.ReadInt();
				m_DamageMin = reader.ReadInt();
				m_DamageMax = reader.ReadInt();
			}

			if ( version >= 7 && version < 18) // Adam: eliminate crazy resistances ver. 18
			{
				int dummy;
				dummy = reader.ReadInt();	// PhysicalResistance
				dummy = reader.ReadInt();	// PhysicalDamage
				dummy = reader.ReadInt();	// FireResistance
				dummy = reader.ReadInt();	// FireDamage
				dummy = reader.ReadInt();	// ColdResistance
				dummy = reader.ReadInt();	// ColdDamage
				dummy = reader.ReadInt();	// PoisonResistance
				dummy = reader.ReadInt();	// PoisonDamage
				dummy = reader.ReadInt();	// EnergyResistance
				dummy = reader.ReadInt();	// EnergyDamage
			}

			//if ( version >= 7 && version >= 18) // Adam: eliminate crazy resistances ver. 18
			//{
			//	m_PhysicalResistance = reader.ReadInt();
			//	m_PhysicalDamage = reader.ReadInt();
			//}

			if ( version >= 8 )
				m_Owners = reader.ReadMobileList();
			else
				m_Owners = new ArrayList();

			if ( version >= 10 )
			{
				m_IsDeadPet = reader.ReadBool();
				m_IsBonded = reader.ReadBool();
				m_BondingBegin = reader.ReadDateTime();
				m_OwnerAbandonTime = reader.ReadDateTime();
			}

			if ( version >= 11 )
				m_HasGeneratedLoot = reader.ReadBool();
			else
				m_HasGeneratedLoot = true;

			if( version >= 12 )
			{
				m_StatLossTime = reader.ReadDateTime();
			}

			if( version >= 13 ) //Pigpen - Addition for IOB Sytem
			{
				m_IOBAlignment = (IOBAlignment)reader.ReadInt();
			}

			if( version >= 14 ) //Pix: IOBLeader/IOBFollower
			{
				m_IOBFollower = reader.ReadBool();
				m_IOBLeader = reader.ReadMobile();
			}

			if( version >= 15 ) //Pix: Spawner
			{
				m_Spawner = (Spawner)reader.ReadItem();
			}

			if( version >= 16 ) //Pix: Lifespan
			{
				m_lifespan = reader.ReadDeltaTime();
			}
			if( version >= 17 && version < 30 ) //Kit: preferred target ai
			{	// eliminated in version 30
				//m_preferred = reader.ReadBool();
				//m_preferredTargetType = reader.ReadMobile();
				//Sortby = (SortTypes)reader.ReadInt();
				reader.ReadBool();
				reader.ReadMobile();
				reader.ReadInt();
			}
			if( version >= 18 ) //Adam: eliminate stupid resistances
			{
				// see above - version 7
			}
			if( version >= 19 ) //Kit: NavStar
			{
				Destination = reader.ReadPoint3D();

				dest = (NavDestinations)reader.ReadInt();

				Nav = (NavBeacon)reader.ReadItem();
			}
			if( version >= 20 ) //Adam: convert BardImmune from an override to a property
			{
				m_bBardImmune = reader.ReadBool();
			}

			if(version >= 21 )
			{
				loyaltyfeed = reader.ReadDateTime();
			}

			if(version >= 22)
			{
				m_Flags = (CreatureFlags)reader.ReadInt();
			}

			if (version >= 24)
			{
				m_ControlSlotModifier = reader.ReadDouble();
				m_Patience = reader.ReadInt();
				m_Wisdom = reader.ReadInt();
				m_Temper = reader.ReadInt();
				m_MaxLoyalty = reader.ReadInt();
			}

            if (version >= 25)
            {
                m_HitsRegenGene = reader.ReadDouble();
                m_ManaRegenGene = reader.ReadDouble();
                m_StamRegenGene = reader.ReadDouble();
            }

            // note the LESS THAN symbol instead of GTE
            // this is an example of run-once deserialization code - every old critter will run this once.
            if (version < 26)
                InitializeGenes();

            // version 27
            if (version >= 27)
                m_LifespanMinutes = reader.ReadInt();

			// we need to reset this because reading the Flags will have turned it off
			//	the flags value will obnly be valid when version >= 28
			if (version < 28)
				IsScaredOfScaryThings = true;

			/*	versions < 29 get their FightMode upgraded to the new [Flags] version
			public enum FightMode
			{
				None,			// Never focus on others
				Aggressor,		// Only attack Aggressors
				Strongest,		// Attack the strongest
				Weakest,		// Attack the weakest
				Closest, 		// Attack the closest
				Evil,			// Only attack aggressor -or- negative karma
				Criminal,		// Attack the criminals
				Player
			}
			 */
			if (version < 29)
			{
				switch ((int)m_FightMode)
				{	// now outdated values
					case 0: m_FightMode = (FightMode)0x00; break;	/*None*/
					case 1: m_FightMode = (FightMode)0x01; break;	/*Aggressor*/
					case 2: m_FightMode = (FightMode)0x02; break;	/*Strongest*/
					case 3: m_FightMode = (FightMode)0x04; break;	/*Weakest*/
					case 4: m_FightMode = (FightMode)0x08; break;	/*Closest*/
					case 5: m_FightMode = (FightMode)0x10; break;	/*Evil*/
					case 6: m_FightMode = (FightMode)0x20; break;	/*Criminal*/
					case 7: m_FightMode = (FightMode)0x40; break;	/*Player*/
				}
			}

			/* versions < 30 get their FightMode upgraded to the new [Flags] version
			public enum FightMode
			{
				None		= 0x00,		// Never focus on others
				Aggressor	= 0x01,		// Only attack Aggressors
				Strongest	= 0x02,		// Attack the strongest
				Weakest		= 0x04,		// Attack the weakest
				Closest		= 0x08, 	// Attack the closest
				Evil		= 0x10,		// Only attack aggressor -or- negative karma
				Criminal	= 0x20,		// Attack the criminals
				Player		= 0x40		// Attack Players (Vampires for feeding on blood)
			}
			 */
			if (version < 30)
			{
				switch ((int)m_FightMode)
				{
					case 0x00 /*None*/		: m_FightMode = FightMode.None; break;
					case 0x01 /*Aggressor*/	: m_FightMode = FightMode.Aggressor; break;
					case 0x02 /*Strongest*/	: m_FightMode = FightMode.All | FightMode.Strongest; break;
					case 0x04 /*Weakest*/	: m_FightMode = FightMode.All | FightMode.Weakest; break;
					case 0x08 /*Closest*/	: m_FightMode = FightMode.All | FightMode.Closest; break;
					case 0x10 /*Evil*/		: m_FightMode = FightMode.Aggressor | FightMode.Evil; break;
					case 0x20 /*Criminal*/	: m_FightMode = FightMode.Aggressor | FightMode.Criminal; break;
					case 0x40 /*Player*/	: m_FightMode = FightMode.All | FightMode.Closest; break;
				}
			}

			// new Fight Style for enhanced AI
			if (version >= 31)
				m_FightStyle = (FightStyle)reader.ReadInt();

			// version 32, read in the AI data, but we must construct the AI object first
			ChangeAIType(m_CurrentAI);
			if (version >= 32)
			{
				if (AIObject != null)
					AIObject.Deserialize(reader);
			}

			if (version >= 33)
			{
				m_ConstantFocus = reader.ReadMobile();
			}

			// -------------------------------
			// After all the reading is done
			// -------------------------------
			RefreshLifespan();
			CheckStatTimers();
			AddFollowers();
		}
예제 #9
0
		public BaseCreature(AIType ai,
			FightMode mode,
			int iRangePerception,
			int iRangeFight,
			double dActiveSpeed,
			double dPassiveSpeed)
		{

			if ( iRangePerception == OldRangePerception )
				iRangePerception = DefaultRangePerception;

			m_Loyalty = PetLoyalty.WonderfullyHappy;

			m_CurrentAI = ai;
			m_DefaultAI = ai;

			m_iRangePerception = iRangePerception;
			m_iRangeFight = iRangeFight;

			m_FightMode = mode;

			m_iTeam = 0;

			//			SpeedInfo.GetSpeeds( this, ref dActiveSpeed, ref dPassiveSpeed );

			m_dActiveSpeed = dActiveSpeed;
			m_dPassiveSpeed = dPassiveSpeed;
			m_dCurrentSpeed = dPassiveSpeed;

			m_arSpellAttack = new ArrayList();
			m_arSpellDefense = new ArrayList();

			m_bControled = false;
			m_ControlMaster = null;
			m_ControlTarget = null;
			m_ControlOrder = OrderType.None;

			m_bTamable = false;

			m_Owners = new ArrayList();

			m_NextReAcquireTime = DateTime.Now + ReacquireDelay;

			ChangeAIType(AI);

			InhumanSpeech speechType = this.SpeechType;

			if ( speechType != null )
				speechType.OnConstruct( this );

			//Pix: comment this out - we don't want RunUO/OSI loot model
			//GenerateLoot( true );

			//new creature, give it a lifespan
			RefreshLifespan();

			InitializeGenes();

			// default for all creatures
			// pay special attention to the (version < 28) case in Deserialize()
			IsScaredOfScaryThings = true;
		}
예제 #10
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            //VirtualArmorMod = -2;

            int version = reader.ReadInt();

            m_CurrentAI = (AIType)reader.ReadInt();
            m_DefaultAI = (AIType)reader.ReadInt();

            m_iRangePerception = reader.ReadInt();
            m_iRangeFight = reader.ReadInt();

            m_iTeam = reader.ReadInt();

            m_dActiveSpeed = reader.ReadDouble();
            m_dPassiveSpeed = reader.ReadDouble();
            m_dCurrentSpeed = reader.ReadDouble();

            double activeSpeed = m_dActiveSpeed;
            double passiveSpeed = m_dPassiveSpeed;

            SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );

            bool isStandardActive = false;
            for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
                isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );

            bool isStandardPassive = false;
            for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
                isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );

            if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
                m_dCurrentSpeed = activeSpeed;
            else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
                m_dCurrentSpeed = passiveSpeed;

            if ( isStandardActive )
                m_dActiveSpeed = activeSpeed;

            if ( isStandardPassive )
                m_dPassiveSpeed = passiveSpeed;

            if ( m_iRangePerception == OldRangePerception )
                m_iRangePerception = DefaultRangePerception;

            m_pHome.X = reader.ReadInt();
            m_pHome.Y = reader.ReadInt();
            m_pHome.Z = reader.ReadInt();

            if ( version >= 1 )
            {
                m_iRangeHome = reader.ReadInt();

                int i, iCount;

                iCount = reader.ReadInt();
                for ( i=0; i< iCount; i++ )
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType( str );

                    if ( type != null )
                    {
                        m_arSpellAttack.Add( type );
                    }
                }

                iCount = reader.ReadInt();
                for ( i=0; i< iCount; i++ )
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType( str );

                    if ( type != null )
                    {
                        m_arSpellDefense.Add( type );
                    }
                }
            }
            else
            {
                m_iRangeHome = 0;
            }

            if ( version >= 2 )
            {
                m_FightMode = ( FightMode )reader.ReadInt();

                m_bControled = reader.ReadBool();
                m_ControlMaster = reader.ReadMobile();
                m_ControlTarget = reader.ReadMobile();
                m_ControlDest = reader.ReadPoint3D();
                m_ControlOrder = (OrderType) reader.ReadInt();

                m_dMinTameSkill = reader.ReadDouble();

                if ( version < 9 )
                    reader.ReadDouble();

                m_bTamable = reader.ReadBool();
                m_bSummoned = reader.ReadBool();

                if ( m_bSummoned )
                {
                    m_SummonEnd = reader.ReadDeltaTime();
                    new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
                }

                m_iControlSlots = reader.ReadInt();
            }
            else
            {
                m_FightMode = FightMode.Closest;

                m_bControled = false;
                m_ControlMaster = null;
                m_ControlTarget = null;
                m_ControlOrder = OrderType.None;
            }

            if ( version >= 3 )
                m_Loyalty = (PetLoyalty)reader.ReadInt();
            else
                m_Loyalty = PetLoyalty.WonderfullyHappy;

            if ( version >= 4 )
                m_CurrentWayPoint = reader.ReadItem() as WayPoint;

            if ( version >= 5 )
                m_SummonMaster = reader.ReadMobile();

            if ( version >= 6 )
            {
                m_HitsMax = reader.ReadInt();
                m_StamMax = reader.ReadInt();
                m_ManaMax = reader.ReadInt();
                m_DamageMin = reader.ReadInt();
                m_DamageMax = reader.ReadInt();
            }

            if ( version >= 7 )
            {
                m_PhysicalResistance = reader.ReadInt();
                m_PhysicalDamage = reader.ReadInt();

                m_FireResistance = reader.ReadInt();
                m_FireDamage = reader.ReadInt();

                m_ColdResistance = reader.ReadInt();
                m_ColdDamage = reader.ReadInt();

                m_PoisonResistance = reader.ReadInt();
                m_PoisonDamage = reader.ReadInt();

                m_EnergyResistance = reader.ReadInt();
                m_EnergyDamage = reader.ReadInt();
            }

            if ( version >= 8 )
                m_Owners = reader.ReadMobileList();
            else
                m_Owners = new ArrayList();

            if ( version >= 10 )
            {
                m_IsDeadPet = reader.ReadBool();
                m_IsBonded = reader.ReadBool();
                m_BondingBegin = reader.ReadDateTime();
                m_OwnerAbandonTime = reader.ReadDateTime();
            }

            if ( Controled && !Owners.Contains( ControlMaster ) )
                Owners.Add( ControlMaster );

            CheckStatTimers();

            ChangeAIType(m_CurrentAI);

            AddFollowers();
        }