Exemple #1
0
        public virtual void UpdateDelta()
        {
            var    eable    = Map.GetClientsInRange(Location);
            Mobile beholder = null;

            Packet status = Packet.Acquire(new MobileHitsN(this));

            foreach (NetState ns in eable)
            {
                beholder = ns.Mobile;

                if (beholder != null && beholder.CanSee(this))
                {
                    ns.Send(status);
                }
            }

            Packet.Release(status);
            eable.Free();
        }
Exemple #2
0
        public void GuildChat(Mobile from, int hue, string text)
        {
            Packet p = null;

            for (int i = 0; i < Members.Count; i++)
            {
                Mobile m = Members[i];

                NetState state = m.NetState;

                if (state != null)
                {
                    p ??= Packet.Acquire(new UnicodeMessage(from.Serial, from.Body, MessageType.Guild, hue, 3, from.Language, from.Name, text));

                    state.Send(p);
                }
            }

            Packet.Release(p);
        }
Exemple #3
0
        public void Add(Mobile m)
        {
            PartyMemberInfo mi = this[m];

            if (mi == null)
            {
                m_Members.Add(new PartyMemberInfo(m));
                m.Party = this;

                Packet memberList = Packet.Acquire(new PartyMemberList(this));
                Packet attrs      = Packet.Acquire(new MobileAttributesN(m));

                for (int i = 0; i < m_Members.Count; ++i)
                {
                    Mobile f = ((PartyMemberInfo)m_Members[i]).Mobile;

                    f.Send(memberList);

                    if (f != m)
                    {
                        f.Send(new MobileStatusCompact(m.CanBeRenamedBy(f), m));
                        f.Send(attrs);
                        m.Send(new MobileStatusCompact(f.CanBeRenamedBy(m), f));
                        m.Send(new MobileAttributesN(f));
                        #region GeNova: KR Support
                        for (int i2 = 0; i2 < m_Members.Count; ++i2)
                        {
                            Mobile f2 = ((PartyMemberInfo)m_Members[i2]).Mobile;
                            if (f2.NetState != null && f2.NetState.IsKRClient)
                            {
                                f2.NetState.Send(new DisplayWaypoint(f.Serial, f.X, f.Y, f.Z, f.Map.MapID, 2, f.Name));
                            }
                        }
                        #endregion
                    }
                }

                Packet.Release(memberList);
                Packet.Release(attrs);
            }
        }
Exemple #4
0
        private void SendToStaffMessage(Mobile from, string text)
        {
            Packet p = null;

            foreach (NetState ns in from.GetClientsInRange(8))
            {
                Mobile mob = ns.Mobile;

                if (mob != null && mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > from.AccessLevel && mob.Party != this && !m_Listeners.Contains(mob))
                {
                    if (p == null)
                    {
                        p = Packet.Acquire(new UnicodeMessage(from.Serial, from.Body, MessageType.Regular, from.SpeechHue, 3, from.Language, from.Name, text));
                    }

                    ns.Send(p);
                }
            }

            Packet.Release(p);
        }
Exemple #5
0
        public void OnStamChanged(Mobile m)
        {
            Packet p = null;

            for (var i = 0; i < Members.Count; ++i)
            {
                var c = Members[i].Mobile;

                if (c != m && m.Map == c.Map && Utility.InUpdateRange(c, m) && c.CanSee(m))
                {
                    if (p == null)
                    {
                        p = Packet.Acquire(new MobileStamN(m));
                    }

                    c.Send(p);
                }
            }

            Packet.Release(p);
        }
Exemple #6
0
        public void OnManaChanged(Mobile m)
        {
            Packet p = null;

            for (int i = 0; i < m_Members.Count; ++i)
            {
                Mobile c = m_Members[i].Mobile;

                if (c != m && m.Map == c.Map && Utility.InUpdateRange(c, m) && c.CanSee(m))
                {
                    if (p == null)
                    {
                        p = Packet.Acquire(new MobileManaN(m));
                    }

                    c.Send(p);
                }
            }

            Packet.Release(p);
        }
Exemple #7
0
        public virtual void Damage(int amount, Mobile from)
        {
            if (!CanDamage && from.Combatant == this)
            {
                from.Combatant = null;
                return;
            }

            Hits -= amount;

            if (amount > 0)
            {
                RegisterDamage(from, amount);
            }

            if (HitEffect > 0)
            {
                Effects.SendLocationEffect(Location, Map, HitEffect, 10, 5);
            }

            NetState theirState = (from == null ? null : from.NetState);

            if (theirState == null && from != null)
            {
                Mobile master = from.GetDamageMaster(null);

                if (master != null)
                {
                    theirState = master.NetState;
                }
            }

            if (amount > 0 && theirState != null)
            {
                theirState.Send(Packet.Acquire(new DamagePacket(this, amount)));
            }

            OnDamage(amount, from, Hits < 0);
        }
Exemple #8
0
        private static void Send(Map map, Point3D loc, int itemID, int hue, string name, string speech)
        {
            var fx = EffectItem.Create(loc, map, EffectItem.DefaultDuration);

            Packet p = null;

            var eable = map.GetClientsInRange(loc, Core.GlobalMaxUpdateRange);

            foreach (var state in eable)
            {
                if (p == null)
                {
                    p = Packet.Acquire(new UnicodeMessage(fx.Serial, itemID, MessageType.Label, hue, 1, "ENU", name, speech));
                }

                state.Send(p);
            }

            Packet.Release(p);

            eable.Free();
        }
Exemple #9
0
        public static void PrivateOverheadMessage(this Item item, MessageType type, int hue, int number, NetState state, string args = "")
        {
            if (item.Map != null && state != null)
            {
                Packet  p        = null;
                Point3D worldLoc = item.GetWorldLocation();

                Mobile m = state.Mobile;

                if (m != null && m.CanSee(item) && m.InRange(worldLoc, item.GetUpdateRange(m)))
                {
                    if (p == null)
                    {
                        p = Packet.Acquire(new MessageLocalized(item.Serial, item.ItemID, type, hue, 3, number, item.Name, args));
                    }

                    state.Send(p);
                }

                Packet.Release(p);
            }
        }
Exemple #10
0
        public static void SendTargetParticles(IEntity target, int itemID, int speed, int duration, int effect, EffectLayer layer, int unknown = 0, int hue = 0, int renderMode = 0)
        {
            if (target is Mobile)
            {
                ((Mobile)target).ProcessDelta();
            }
            var map = target.Map;

            if (map != null)
            {
                Packet particles = null, regular = null;
                var    eable = map.GetClientsInRange(target.Location);
                foreach (var state in eable)
                {
                    state.Mobile.ProcessDelta();
                    if (SendParticlesTo(state))
                    {
                        if (particles == null)
                        {
                            particles = Packet.Acquire(new TargetParticleEffect(target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown));
                        }
                        state.Send(particles);
                    }
                    else if (itemID != 0)
                    {
                        if (regular == null)
                        {
                            regular = Packet.Acquire(new TargetEffect(target, itemID, speed, duration, hue, renderMode));
                        }
                        state.Send(regular);
                    }
                }
                Packet.Release(particles);
                Packet.Release(regular);
                eable.Free();
            }
            //SendPacket(target.Location, target.Map, new TargetParticleEffect(target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown));
        }
Exemple #11
0
        public static void ZombieDeathAnim(Mobile mob, Corpse c)
        {
            if (mob == null || mob.Map == null)
            {
                return;
            }

            Packet animPacket = null; //new DeathAnimation( this, c );
            Packet remPacket  = null; //this.RemovePacket;

            IPooledEnumerable eable = mob.Map.GetClientsInRange(mob.Location);

            foreach (NetState state in eable.OfType <NetState>().Where(state => state != mob.NetState))
            {
                if (animPacket == null)
                {
                    animPacket = Packet.Acquire(new DeathAnimation(mob, c));
                }

                state.Send(animPacket);

                if (state.Mobile.CanSee(mob))
                {
                    continue;
                }

                if (remPacket == null)
                {
                    remPacket = mob.RemovePacket;
                }

                state.Send(remPacket);
            }

            Packet.Release(animPacket);

            eable.Free();
        }
Exemple #12
0
            protected override void OnTick()
            {
                Party p = Get(m_Mobile);

                if (p == null)
                {
                    return;
                }

                m_Mobile.SendLocalizedMessage(1005437); // You have rejoined the party.
                m_Mobile.Send(new PartyMemberList(p));

                Packet message = Packet.Acquire(new MessageLocalizedAffix(Serial.MinusOne, -1, MessageType.Label, 0x3B2, 3, 1008087, "", AffixType.Prepend | AffixType.System, m_Mobile.Name, ""));
                Packet attrs   = Packet.Acquire(new MobileAttributesN(m_Mobile));

                for (var index = 0; index < p.Members.Count; index++)
                {
                    PartyMemberInfo mi = p.Members[index];
                    Mobile          m  = mi.Mobile;

                    if (m != m_Mobile)
                    {
                        m.Send(message);
                        m.Send(new MobileStatusCompact(m_Mobile.CanBeRenamedBy(m), m_Mobile));
                        m.Send(attrs);
                        m_Mobile.Send(new MobileStatusCompact(m.CanBeRenamedBy(m_Mobile), m));
                        m_Mobile.Send(new MobileAttributesN(m));

                        if (m_Mobile.NetState != null && m_Mobile.NetState.IsEnhancedClient)
                        {
                            Waypoints.Create(m_Mobile, m, WaypointType.PartyMember);
                        }
                    }
                }

                Packet.Release(message);
                Packet.Release(attrs);
            }
Exemple #13
0
 public static void PlaySound(IPoint3D p, Map map, int soundID)
 {
     if (soundID <= -1)
     {
         return;
     }
     if (map != null)
     {
         Packet playSound = null;
         var    eable     = map.GetClientsInRange(new Point3D(p));
         foreach (var state in eable)
         {
             state.Mobile.ProcessDelta();
             if (playSound == null)
             {
                 playSound = Packet.Acquire(new PlaySound(soundID, p));
             }
             state.Send(playSound);
         }
         Packet.Release(playSound);
         eable.Free();
     }
 }
Exemple #14
0
		public void GuildChat(Mobile from, int hue, string text)
		{
			Packet p = null;

			foreach (Mobile m in OnlineMembers)
			{
				NetState state = m.NetState;

				if (state != null)
				{
					if (p == null)
					{
						p =
							Packet.Acquire(
								new UnicodeMessage(from.Serial, from.Body, MessageType.Guild, hue, 3, from.Language, from.Name, text));
					}

					state.Send(p);
				}
			}

			Packet.Release(p);
		}
Exemple #15
0
        public void SendToAll(Packet p)
        {
            p.Acquire();

            for (int i = 0; i < m_Members.Count; ++i)
            {
                m_Members[i].Mobile.Send(p);
            }

            if (p is MessageLocalized || p is MessageLocalizedAffix || p is UnicodeMessage || p is AsciiMessage)
            {
                for (int i = 0; i < m_Listeners.Count; ++i)
                {
                    Mobile mob = m_Listeners[i];

                    if (mob.Party != this)
                    {
                        mob.Send(p);
                    }
                }
            }

            p.Release();
        }
Exemple #16
0
        public override void OnThink()
        {
            base.OnThink();

            if (m_NextShout <= DateTime.UtcNow)
            {
                Packet shoutPacket = null;

                foreach (var state in GetClientsInRange(12))
                {
                    var m = state.Mobile;

                    if (m.CanSee(this) && m.InLOS(this) && m.CanBeginAction(this))
                    {
                        shoutPacket ??= Packet.Acquire(
                            new MessageLocalized(
                                Serial,
                                Body,
                                MessageType.Regular,
                                946,
                                3,
                                1078099,
                                Name,
                                ""
                                )
                            ); // Double Click On Me For Help!

                        state.Send(shoutPacket);
                    }
                }

                Packet.Release(shoutPacket);

                m_NextShout = DateTime.UtcNow + m_ShoutDelay;
            }
        }
Exemple #17
0
        protected override void OnTick()
        {
            Effects.SendLocationParticles(effectItem, itemId, speed, duration, effect);
            if (sound >= 0)
            {
                if (imap != null)
                {
                    Packet p = Packet.Acquire(new PlaySound(sound, iloc));

                    IPooledEnumerable <NetState> eable = imap.GetClientsInRange(iloc);

                    foreach (NetState state in eable)
                    {
                        state.Send(p);
                    }

                    Packet.Release(p);

                    eable.Free();
                }

                if (dmg > 0)
                {
                    IPooledEnumerable <Mobile> eable = imap.GetMobilesInRange(iloc);

                    foreach (Mobile mob in eable)
                    {
                        mob.Damage(50, null, true);
                    }

                    eable.Free();
                }
            }

            this.Stop();
        }
Exemple #18
0
        public void AllianceChat(Mobile from, int hue, string text)
        {
            Packet p = null;

            for (var i = 0; i < m_Members.Count; i++)
            {
                var g = m_Members[i];

                for (var j = 0; j < g.Members.Count; j++)
                {
                    var m = g.Members[j];

                    var state = m.NetState;

                    if (state != null)
                    {
                        p ??= Packet.Acquire(
                            new UnicodeMessage(
                                from.Serial,
                                from.Body,
                                MessageType.Alliance,
                                hue,
                                3,
                                from.Language,
                                from.Name,
                                text
                                )
                            );

                        state.Send(p);
                    }
                }
            }

            Packet.Release(p);
        }
        public void InvalidatePose()
        {
            UpdateStatueDelayed();
            switch (m_Pose)
            {
            case StatuePose.Ready:
                m_Animation = 4;
                m_Frames    = 0;
                break;

            case StatuePose.Casting:
                m_Animation = 16;
                m_Frames    = 2;
                break;

            case StatuePose.Salute:
                m_Animation = 33;
                m_Frames    = 1;
                break;

            case StatuePose.AllPraiseMe:
                m_Animation = 17;
                m_Frames    = 4;
                break;

            case StatuePose.Fighting:
                m_Animation = 31;
                m_Frames    = 5;
                break;

            case StatuePose.HandsOnHips:
                m_Animation = 6;
                m_Frames    = 1;
                break;
            }

            if (Map == null)
            {
                return;
            }

            ProcessDelta();

            Packet p = null;

            IPooledEnumerable eable = Map.GetClientsInRange(Location);

            foreach (NetState state in eable)
            {
                state.Mobile.ProcessDelta();

                if (p == null)
                {
                    p = Packet.Acquire(new UpdateStatueAnimationSA(this, m_Animation, m_Frames));
                }

                state.Send(p);
            }

            Packet.Release(p);

            eable.Free();
        }
Exemple #20
0
        public virtual void OnTick()
        {
            if (m_Stage == 0)
            {
                m_Active             = (m_ChanceOfPercipitation > Utility.Random(100));
                m_ExtremeTemperature = (m_ChanceOfExtremeTemperature > Utility.Random(100));

                if (m_MoveSpeed > 0)
                {
                    Reposition();
                    RecalculateMovementAngle();
                }
            }

            if (m_Active)
            {
                if (m_Stage > 0 && m_MoveSpeed > 0)
                {
                    MoveForward();
                }

                int type, density, temperature;

                temperature = m_Temperature;

                if (m_ExtremeTemperature)
                {
                    temperature *= -1;
                }

                if (m_Stage < 15)
                {
                    density = m_Stage * 5;
                }
                else
                {
                    density = 150 - (m_Stage * 5);

                    if (density < 10)
                    {
                        density = 10;
                    }
                    else if (density > 70)
                    {
                        density = 70;
                    }
                }

                if (density == 0)
                {
                    type = 0xFE;
                }
                else if (temperature > 0)
                {
                    type = 0;
                }
                else
                {
                    type = 2;
                }

                List <NetState> states = NetState.Instances;

                Packet weatherPacket = null;

                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns  = states[i];
                    Mobile   mob = ns.Mobile;

                    if (mob == null || mob.Map != m_Facet)
                    {
                        continue;
                    }

                    bool contains = (m_Area.Length == 0);

                    for (int j = 0; !contains && j < m_Area.Length; ++j)
                    {
                        contains = m_Area[j].Contains(mob.Location);
                    }

                    if (!contains)
                    {
                        continue;
                    }

                    if (weatherPacket == null)
                    {
                        weatherPacket = Packet.Acquire(new UltimaOnline.Network.Weather(type, density, temperature));
                    }

                    ns.Send(weatherPacket);
                }

                Packet.Release(weatherPacket);
            }

            m_Stage++;
            m_Stage %= 30;
        }
Exemple #21
0
        public virtual void OnTick()
        {
            if (m_Stage == 0)
            {
                m_Active             = (m_ChanceOfPercipitation > Utility.Random(100));
                m_ExtremeTemperature = (m_ChanceOfExtremeTemperature > Utility.Random(100));

                if (m_MoveSpeed > 0)
                {
                    Reposition();
                    RecalculateMovementAngle();
                }
            }

            if (m_Active)
            {
                if (m_Stage > 0 && m_MoveSpeed > 0)
                {
                    MoveForward();
                }

                int type, density, temperature;

                temperature = m_Temperature;

                if (m_ExtremeTemperature)
                {
                    temperature *= -1;
                }

                if (m_Stage < 15)
                {
                    density = m_Stage * 5;
                }
                else
                {
                    density = 150 - (m_Stage * 5);

                    if (density < 10)
                    {
                        density = 10;
                    }
                    else if (density > 70)
                    {
                        density = 70;
                    }
                }

                if (density == 0)
                {
                    type = 0xFE;
                }
                else if (temperature > 0)
                {
                    type = 0;
                }
                else
                {
                    type = 2;
                }

                List <NetState> states = NetState.Instances;

                Packet weatherPacket = null;

                String msg = String.Empty;
                if (Utility.RandomDouble() > 0.9)
                {
                    switch (Utility.RandomMinMax(0, 5))
                    {
                    case 0: msg = "La foudre retentie";
                        break;

                    case 1: msg = "La foudre s'abbat au loin";
                        break;

                    case 2: msg = "Le tonerre gronde violement";
                        break;

                    case 3: msg = "Un éclair traverse le ciel";
                        break;

                    case 4: msg = "Un éclair frappe la terre au loin";
                        break;

                    case 5: msg = "La foudre déchire le ciel";
                        break;
                    }
                }
                if (msg != String.Empty)
                {
                    World.Broadcast(0x35, true, msg);
                }

                //Console.WriteLine("OnTick Weather");
                bool asFind = false;
                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns  = states[i];
                    Mobile   mob = ns.Mobile;

                    if (mob == null || mob.Map != m_Facet)
                    {
                        continue;
                    }

                    bool contains = (m_Area.Length == 0);

                    for (int j = 0; !contains && j < m_Area.Length; ++j)
                    {
                        contains = m_Area[j].Contains(mob.Location);
                    }

                    if (!contains)
                    {
                        continue;
                    }

                    //Nexam AddOn
                    density *= 3;
                    //mob.LightLevel -= 20;

                    //FOUDRE

                    if (mob is NubiaPlayer)
                    {
                        //Console.WriteLine("Foudre vers "+mob.Name );
                        //for(int nb = 0; nb < 3; nb++)
                        Region reg          = mob.Region;
                        bool   canRegFoudre = true;
                        if (reg is BaseNubiaRegion)
                        {
                            Console.WriteLine("CanFoudre pour la region {0} = {1}", reg, ((BaseNubiaRegion)reg).CanFoudre);
                            canRegFoudre = ((BaseNubiaRegion)reg).CanFoudre;
                        }
                        if (canRegFoudre)
                        {
                            if (30 >= Utility.RandomMinMax(0, 100))
                            {
                                StormHelper.RandomFoudre(new Rectangle2D(mob.X - 25, mob.Y - 25, 50, 50), m_Facet);
                            }
                            else if (30 >= Utility.RandomMinMax(0, 100))
                            {
                                StormHelper.RandomFoudre(new Rectangle2D(mob.X - 10, mob.Y - 10, 20, 20), m_Facet);
                            }

                            if (10 >= Utility.RandomMinMax(0, 100) && mob.Alive)
                            {
                                bool canFoudre = true;
                                foreach (Item item in mob.GetItemsInRange(3))
                                {
                                    if (item is BriseTonnerre)
                                    {
                                        Effects.SendBoltEffect(item);
                                        Effects.SendBoltEffect(item);
                                        canFoudre = false;
                                    }
                                }

                                /*if( NubiaHelper.HaveBuff( typeof( SymbioseNature ), mob as NubiaPlayer )){
                                 *      mob.Emote("*Imunisé à la foudre*");
                                 *      canFoudre = false;
                                 * }
                                 * else*/if (canFoudre)
                                {
                                    mob.Emote("*Frappé par  Foudre !*");
                                    mob.Damage(Utility.RandomMinMax(120, 220));
                                    new FoudreDebuff(mob as NubiaPlayer);
                                }

                                if (canFoudre)
                                {
                                    mob.BoltEffect(0);
                                    ImpactItem impact = new ImpactItem(false);
                                    impact.MoveToWorld(new Point3D(mob.X, mob.Y, mob.Z + 1), mob.Map);
                                    impact.Construct();
                                }
                            }
                        }
                        else if (Utility.Random(50) == 1)
                        {
                            mob.SendMessage("Les éclairs se brisent sur un dome invisible recouvrant la ville.");
                        }
                    }


                    if (weatherPacket == null)
                    {
                        weatherPacket = Packet.Acquire(new Server.Network.Weather(type, density, temperature));
                    }

                    ns.Send(weatherPacket);
                    asFind = true;
                }

                //FOUDRE !!!

                /*if( m_Facet == Map.Felucca && asFind ) //Region trammel et qq dans la zone de pluie ^^
                 * {
                 *      for( int f = 0; f < m_Area.Length; f++)
                 *      {
                 *              for(int fnb = 0; fnb < 10; fnb++)
                 *                      StormHelper.RandomFoudre(m_Area[f], m_Facet);
                 *      }
                 * }*/

                Packet.Release(weatherPacket);
            }

            m_Stage++;
            m_Stage %= 30;
        }
Exemple #22
0
        public virtual void Weather_OnTick()
        {
            int  type             = 0xFE;
            int  density          = 0;
            int  temperature      = IsUnderZero ? -30 : 30;
            bool wasRaining       = IsRaining;
            bool seasonHasChanged = false;

            if (m_NextWeatherChange < DateTime.Now)
            {
                m_Temperature = GenerateTemperature();
                m_Cloud       = GenerateCloud();
                m_Wind        = GenerateWind();

                m_NextWeatherChange = DateTime.Now + Interval;
            }

            if (IsRaining)
            {
                if (!IsUnderZero)
                {
                    type = 0;
                }
                else
                {
                    type = 2;
                }

                if (m_Cloud == DensityOfCloud.FaiblePluie)
                {
                    density = 10;
                }
                else if (m_Cloud == DensityOfCloud.Pluie)
                {
                    density = 40;
                }
                else if (m_Cloud == DensityOfCloud.FortePluie)
                {
                    density = 70;
                }
            }

            int year, month, day;

            Time.GetDate(out year, out month, out day);

            Season season = Time.Months[month - 1].Season;

            if (Map.Felucca.Season != (int)season)
            {
                Map.Felucca.Season = (int)season;
                Time.OnSeasonChange(season);
                seasonHasChanged = true;
            }

            List <NetState> states = NetState.Instances;

            Packet weatherPacket = null;
            Packet seasonPacket  = null;

            for (int i = 0; i < states.Count; ++i)
            {
                NetState ns  = (NetState)states[i];
                Mobile   mob = ns.Mobile;

                if (mob == null || mob.Map != Map.Felucca)
                {
                    continue;
                }

                if (seasonHasChanged)
                {
                    if (seasonPacket == null)
                    {
                        seasonPacket = Packet.Acquire(new SeasonChange(Map.Felucca.Season, false));
                    }

                    ns.Send(seasonPacket);

                    mob.CheckLightLevels(false);
                }

                bool contains = (m_Area.Length == 0);

                for (int j = 0; !contains && j < m_Area.Length; ++j)
                {
                    contains = m_Area[j].Contains(mob.Location);
                }

                if (!contains)
                {
                    continue;
                }

                if (weatherPacket == null)
                {
                    weatherPacket = Packet.Acquire(new Server.Network.Weather(type, density, temperature));
                }

                ns.Send(weatherPacket);

                if (wasRaining && !IsRaining)
                {
                    ns.Send(new MobileUpdate(mob));
                    ns.Send(new MobileIncoming(mob, mob));
                }

                //ns.Mobile.ProcessDelta();
            }
        }
Exemple #23
0
        public virtual void OnTick()
        {
            if (m_Stage == 0)
            {
                m_Active             = ChanceOfPercipitation > Utility.Random(100);
                m_ExtremeTemperature = ChanceOfExtremeTemperature > Utility.Random(100);

                if (MoveSpeed > 0)
                {
                    Reposition();
                    RecalculateMovementAngle();
                }
            }

            if (m_Active)
            {
                if (m_Stage > 0 && MoveSpeed > 0)
                {
                    MoveForward();
                }

                int type, density;
                var temperature = Temperature;

                if (m_ExtremeTemperature)
                {
                    temperature *= -1;
                }

                if (m_Stage < 15)
                {
                    density = m_Stage * 5;
                }
                else
                {
                    density = 150 - m_Stage * 5;

                    if (density < 10)
                    {
                        density = 10;
                    }
                    else if (density > 70)
                    {
                        density = 70;
                    }
                }

                if (density == 0)
                {
                    type = 0xFE;
                }
                else if (temperature > 0)
                {
                    type = 0;
                }
                else
                {
                    type = 2;
                }

                var states = TcpServer.Instances;

                Packet weatherPacket = null;

                for (var i = 0; i < states.Count; ++i)
                {
                    var ns  = states[i];
                    var mob = ns.Mobile;

                    if (mob == null || mob.Map != Facet)
                    {
                        continue;
                    }

                    var contains = Area.Length == 0;

                    for (var j = 0; !contains && j < Area.Length; ++j)
                    {
                        contains = Area[j].Contains(mob.Location);
                    }

                    if (!contains)
                    {
                        continue;
                    }

                    if (weatherPacket == null)
                    {
                        weatherPacket = Packet.Acquire(new Network.Weather(type, density, temperature));
                    }

                    ns.Send(weatherPacket);
                }

                Packet.Release(weatherPacket);
            }

            m_Stage++;
            m_Stage %= 30;
        }
Exemple #24
0
        protected override void OnTick()
        {
            if (m_flashnade.Deleted)
            {
                Stop();
                return;
            }

            if (m_flashnade.running == false)
            {
                Stop();
                return;
            }

            if (m_count > 1)
            {
                m_count--;

                m_flashnade.PublicOverheadMessage(MessageType.Regular, 957, false, m_count.ToString());

                m_flashnade.CountDown = new countdown_timer(m_from, m_flashnade, m_count);
                m_flashnade.CountDown.Start();
                Stop();
                return;
            }


            IPooledEnumerable eable = m_flashnade.Map.GetMobilesInRange(m_flashnade.Location, m_flashnade.range);

            foreach (object o in eable)
            {
                if (o is Mobile)
                {
                    Mobile m = (Mobile)o;
                    if (m_from != m)
                    {
                        NetState ns = m.NetState;

                        Packet animPacket = Packet.Acquire(new FlashEffect(FlashType.FadeInOut));

                        if (m != null && m is PlayerMobile)
                        {
                            ns.Send(animPacket);
                        }
                    }
                    else if (m_from == m)
                    {
                        NetState ns = m.NetState;

                        Packet animPacket = Packet.Acquire(new FlashEffect(FlashType.LightFlash));

                        if (m != null && m is PlayerMobile)
                        {
                            ns.Send(animPacket);
                        }
                    }
                }
            }


            m_flashnade.Delete();
            Stop();
            return;
        }
Exemple #25
0
        public virtual void OnTick()
        {
            if (m_Stage == 0)
            {
                m_Active             = (m_ChanceOfPercipitation > Utility.Random(100));
                m_ExtremeTemperature = (m_ChanceOfExtremeTemperature > Utility.Random(100));

                if (m_MoveSpeed > 0)
                {
                    Reposition();
                    RecalculateMovementAngle();
                }
            }

            if (m_Active)
            {
                if (m_Stage > 0 && m_MoveSpeed > 0)
                {
                    MoveForward();
                }

                int type, density, temperature;

                temperature = m_Temperature;

                if (m_ExtremeTemperature)
                {
                    temperature *= -1;
                }

                if (m_Stage < 15)
                {
                    density = m_Stage * 5;
                }
                else
                {
                    density = 150 - (m_Stage * 5);

                    if (density < 10)
                    {
                        density = 10;
                    }
                    else if (density > 70)
                    {
                        density = 70;
                    }
                }

                if (density == 0)
                {
                    type = 0xFE;
                }
                else if (temperature > 0)
                {
                    type = 0;
                }
                else
                {
                    type = 2;
                }

                List <NetState> states = NetState.Instances;

                Packet weatherPacket = null;

                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns  = states[i];
                    Mobile   mob = ns.Mobile;

                    if (mob == null || mob.Map != m_Facet)
                    {
                        continue;
                    }

                    bool contains = (m_Area.Length == 0);

                    for (int j = 0; !contains && j < m_Area.Length; ++j)
                    {
                        contains = m_Area[j].Contains(mob.Location);
                    }

                    if (!contains)
                    {
                        continue;
                    }

                    if (weatherPacket == null)
                    {
                        weatherPacket = Packet.Acquire(new Server.Network.Weather(type, density, temperature));
                    }
                    bool      IsInside = false;
                    BaseHouse house    = null;
                    if (mob != null)
                    {
                        house = BaseHouse.FindHouseAt(mob.Location, mob.Map, 20);
                        if (house != null)
                        {
                            IsInside = true;
                        }
                    }

                    PlayerMobile pm = mob as PlayerMobile;

                    if (m_ExtremeTemperature)
                    {
                        pm.SendMessage("¡SERA MEJOR QUE TE QUEDES A CUBIERTO, SE AVECINA UN TEMPORAL!");

                        switch (Utility.Random(100))
                        {
                        case 0:
                        {
                            ((PlayerMobile)mob).BoltEffect(0);
                            ((PlayerMobile)mob).Damage(Utility.Random(1, 2));
                            ((PlayerMobile)mob).SendMessage("¡Te ha caido un rayo al lado!");
                            break;
                        }

                        case 1:
                        {
                            ((PlayerMobile)mob).BoltEffect(0);
                            ((PlayerMobile)mob).Damage(Utility.Random(1, 2));
                            ((PlayerMobile)mob).SendMessage("¡Te ha caido un rayo al lado!");
                            break;
                        }

                        case 2:
                        {
                            ((PlayerMobile)mob).BoltEffect(0);
                            ((PlayerMobile)mob).Damage(Utility.Random(1, 2));
                            ((PlayerMobile)mob).SendMessage("¡Te ha caido un rayo al lado!");
                            break;
                        }

                        case 3:
                        {
                            ((PlayerMobile)mob).BoltEffect(0);
                            ((PlayerMobile)mob).Damage(Utility.Random(1, 5));
                            ((PlayerMobile)mob).SendMessage("¡Te ha caido un rayo al lado!");
                            break;
                        }

                        case 4:
                        {
                            ((PlayerMobile)mob).BoltEffect(0);
                            SpellHelper.Damage(TimeSpan.Zero, (PlayerMobile)mob, Utility.Random(5, 15), 0, 0, 0, 0, 100);
                            ((PlayerMobile)mob).SendMessage("¡Te ha caido un rayo al lado!");
                            break;
                        }

                        case 5:
                        {
                            ((PlayerMobile)mob).BoltEffect(1);
                            SpellHelper.Damage(TimeSpan.Zero, (PlayerMobile)mob, Utility.Random(5, 15), 0, 0, 0, 0, 100);
                            ((PlayerMobile)mob).SendMessage("¡Te ha caido un rayo al lado!");
                            break;
                        }

                        default: break;
                        }
                    }


                    ns.Send(weatherPacket);
                }

                Packet.Release(weatherPacket);
            }

            m_Stage++;
            m_Stage %= 30;
        }