Ejemplo n.º 1
0
        /// <summary>
        /// Spawn override...
        /// </summary>
        public override void Spawn()
        {
            //Before anything else happens, check maintenance time
            if (DateTime.Now > m_NextMaintTime)
            {
                if (m_Silver < MaintCost)
                {
                    //not enough silver so just stop running
                    Running = false;
                    return;
                }
                //Decrease silver and update next spawn time
                m_Silver       -= MaintCost;
                m_NextMaintTime = DateTime.Now + TimeSpan.FromMinutes(KinSystemSettings.GuardMaintMinutes);
                //Provide maint activity
                if (KinCityRegion != null)
                {
                    KinCityRegion.ProcessActivity(KinFactionActivityTypes.GuardPostMaint);
                }
            }

            //Spawn fires every minute, but the guard post has a dynamic spawn time
            //therefore check if we can now spawn ( 0 creatures, these can only spawn one each to keep it simple )
            //if so set the next spawn time based on the speed and then check until this time has passed before spawning
            Defrag();
            if (Creatures.Count == 0)
            {
                if (m_Reset)                    //Need a reset flip so the first time a creature is elgible to spawn, the timer is reset
                {
                    m_NextSpawnTime = DateTime.Now + TimeSpan.FromMinutes(m_SpawnTimeMinutes);
                    m_Reset         = false;
                    return;
                }

                //spawn if poss
                if (DateTime.Now > m_NextSpawnTime && m_Silver >= HireCost)
                {
                    m_Silver -= HireCost;
                    Spawn(0);
                    m_Reset = true;                      //set reset to true so the next time a guard dies the next one has to wait the full respawn time
                    //Provide hire activity
                    if (KinCityRegion != null)
                    {
                        KinCityRegion.ProcessActivity(KinFactionActivityTypes.GuardPostHire);
                    }
                }
                else if (m_Silver < HireCost)
                {
                    Running = false;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when [double click].
        /// </summary>
        /// <param name="from">From.</param>
        public override void OnDoubleClick(Mobile from)
        {
            if (!(from is PlayerMobile))
            {
                return;
            }
            if (CheckRange(from))
            {
                KinCityRegion region = KinCityRegion.GetKinCityAt(this);
                if (region == null)
                {
                    from.SendMessage("This board is not placed within a Kin City");
                    return;
                }

                if (from.AccessLevel <= AccessLevel.Player)
                {
                    KinCityData data = KinCityManager.GetCityData(region.KinFactionCity);
                    if (data == null)
                    {
                        return;
                    }

                    if (data.ControlingKin == IOBAlignment.None)
                    {
                        from.SendMessage("This city is controlled by the Golem Controller Lord!");
                        return;
                    }

                    if (((PlayerMobile)from).IOBRealAlignment != data.ControlingKin)
                    {
                        from.SendMessage("You are not aligned with {0}", data.ControlingKin.ToString());
                        return;
                    }
                }

                from.CloseGump(typeof(KinCityControlGump));
                from.SendGump(new KinCityControlGump(region.KinFactionCity, from));
            }
            else
            {
                from.LocalOverheadMessage(Server.Network.MessageType.Regular, 0x3B2, 1019045);                 // I can't reach that.
            }
        }
Ejemplo n.º 3
0
        public override void OnEnter(Mobile m)
        {
            Region       left = null;
            PlayerMobile pm   = null;

            if (m is PlayerMobile)
            {
                pm   = (PlayerMobile)m;
                left = pm.LastRegionIn;
            }
            // wea: If this is an isolated region, we're going to send sparklies where
            // mobiles will disappear (this happens as part of an IsIsolatedFrom() check,
            // not explicit packet removal here) + a sound effect if we had to do this
            //
            // also send an incoming packet to all players within the region.
            // ____
            // ||
            if (m_Controller.IsIsolated)
            {
                if (m.Map != null)
                {
                    int invissedmobiles = 0;

                    IPooledEnumerable eable = m.GetMobilesInRange(Core.GlobalMaxUpdateRange);

                    foreach (Mobile mir in eable)
                    {
                        // Regardless of whether this is mobile or playermobile,
                        // we need to send an incoming packet to each of the mobiles
                        // in the region

                        if (mir.Region == m.Region)
                        {
                            if (mir is PlayerMobile)
                            {
                                // We've just walked into this mobile's region, so send incoming packet
                                // if they're a playermobile

                                if (Utility.InUpdateRange(m.Location, mir.Location) && mir.CanSee(m))
                                {
                                    // Send incoming packet to player if they're online
                                    if (mir.NetState != null)
                                    {
                                        mir.NetState.Send(new MobileIncoming(mir, m));
                                    }
                                }
                            }
                        }
                        else
                        {
                            // They're in a different region, so localise sparklies
                            // to us if we're a player mobile
                            if (pm != null && mir.AccessLevel <= pm.AccessLevel)
                            {
                                Packet particles = new LocationParticleEffect(EffectItem.Create(mir.Location, mir.Map, EffectItem.DefaultDuration), 0x376A, 10, 10, 0, 0, 2023, 0);

                                if (pm.NetState != null && particles != null)
                                {
                                    pm.Send(particles);
                                    invissedmobiles++;
                                }
                            }
                        }
                    }

                    if (invissedmobiles > 0)
                    {
                        // Play a sound effect to go with it
                        if (pm.NetState != null)
                        {
                            pm.PlaySound(0x3C4);
                        }
                    }

                    if (pm != null)
                    {
                        m.ClearScreen();
                        m.SendEverything();
                    }
                    eable.Free();
                }
            }
            // ||
            // ____

            // if were leaving a house and entering the region(already in it) dont play the enter msg
            if (pm != null && pm.LastRegionIn is HouseRegion)
            {
                return;
            }

            if (m_Controller.ShowEnterMessage)
            {
                m.SendMessage("You have entered {0}", this.Name);

                if (m_Controller.NoMurderZone)
                {
                    m.SendMessage("This is a lawless area; you are freely attackable here.");
                }
            }

            if (m_Controller.OverrideMaxFollowers)
            {
                m.FollowersMax = m_Controller.MaxFollowerSlots;
            }

            if (m_Controller.PlayMusic)
            {
                PlayMusic(m);
            }

            PlayerMobile IOBenemy = null;

            if (m is PlayerMobile)
            {
                IOBenemy = (PlayerMobile)m;
            }

            //if is a iob zone/region and a iob aligned mobile with a differnt alignment then the zone enters
            //find all players of the zones alignment and send them a message
            //plasma: refactored the send message code into its own method within KinSystem
            if (DateTime.Now >= m_Controller.m_Msg && m_Controller.IOBZone && m_Controller.ShowIOBMsg && IOBenemy != null && IOBenemy.IOBAlignment != IOBAlignment.None && IOBenemy.IOBAlignment != m_Controller.IOBAlign && m.AccessLevel == AccessLevel.Player)              //we dont want it announceing staff with iob kinship
            {
                if (m_Controller.RegionName != null && m_Controller.RegionName.Length > 0)
                {
                    KinSystem.SendKinMessage(m_Controller.IOBAlign, string.Format("Come quickly, the {0} are attacking {1}!",
                                                                                  IOBSystem.GetIOBName(IOBenemy.IOBRealAlignment),
                                                                                  m_Controller.RegionName));
                }
                else
                {
                    KinSystem.SendKinMessage(m_Controller.IOBAlign, string.Format("Come quickly, the {0} are attacking your stronghold!",
                                                                                  IOBSystem.GetIOBName(IOBenemy.IOBRealAlignment)));
                }
                m_Controller.m_Msg = DateTime.Now + m_Controller.m_Delay;
            }
            else if (DateTime.Now >= m_Controller.m_Msg && this is Engines.IOBSystem.KinCityRegion && IOBenemy != null && IOBenemy.IOBAlignment != IOBAlignment.None && IOBenemy.IOBAlignment != m_Controller.IOBAlign && m.AccessLevel == AccessLevel.Player)              //we dont want it announceing staff with iob kinship
            {
                KinCityRegion r = KinCityRegion.GetKinCityAt(this.m_Controller);
                if (r != null)
                {
                    KinCityData cd = KinCityManager.GetCityData(r.KCStone.City);
                    if (cd != null && cd.ControlingKin != IOBAlignment.None)
                    {
                        Engines.IOBSystem.KinSystem.SendKinMessage(cd.ControlingKin, string.Format("Come quickly, the {0} are attacking the City of {1}!",
                                                                                                   IOBSystem.GetIOBName(IOBenemy.IOBRealAlignment), cd.City.ToString()));
                        m_Controller.m_Msg = DateTime.Now + m_Controller.m_Delay;
                    }
                }
            }

            base.OnEnter(m);
        }