Beispiel #1
0
        public BaseRTTGump(Mobile from, string strNotice, string strSkill, int x, int y)
            : base(x, y)
        {
            m_Mobile    = from;
            m_strNotify = strNotice;
            m_strSkill  = strSkill;

            this.Closable = false;

            //close any other RTT gumps
            from.CloseGump(typeof(BaseRTTGump));

            // notify staff
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RTTNotifyEnabled))
            {
                Server.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Administrator,
                                                                 0x482,
                                                                 String.Format("{0}({1}) is taking the RTT ({2}).", m_Mobile.Name, m_Mobile.Serial, strSkill));
            }

            // record the fact that the RTT test is being taken
            Server.Commands.LogHelper lh = new Server.Commands.LogHelper("RTT.log", false, true);
            lh.Log(Server.Commands.LogType.Mobile, m_Mobile, String.Format("({0}) RTT Launched.", strSkill));
            lh.Finish();

            //This will call any child-gump's SetupGump and set it up like the child wants.
            SetupGump();

            //Save when we launched the gump for later recording
            m_RTTLaunched = DateTime.Now;

            // if the player fails to respond in 'timeout' time, then we will cound this as an RTT failure.
            //	this does two things: (1) makes the next test 5 minutes from now, (2) will move them closer to being counted as a macroer
            m_timeout = new RTTTimer(m_Mobile, TimeSpan.FromSeconds(Utility.RandomList(90, 120, 180)));
            m_timeout.Start();
        }
Beispiel #2
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            // wea: Correctly clear gumps for newer clients.
            from.CloseGumps(typeof(ResurrectGump));

            if (info.ButtonID == 1 || info.ButtonID == 2)
            {
                if (from is PlayerMobile && ((PlayerMobile)from).Mortal && from.AccessLevel == AccessLevel.Player)
                {
                    from.SendMessage("Thy soul was too closely intertwined with thy flesh - thou'rt unable to incorporate a new body.");
                    return;
                }

                if (from.Map == null || !from.Map.CanFit(from.Location, 16, CanFitFlags.requireSurface))
                {
                    from.SendLocalizedMessage(502391);                     // Thou can not be resurrected there!
                    return;
                }

                if (m_Price > 0)
                {
                    if (info.IsSwitched(1))
                    {
                        if (Banker.Withdraw(from, m_Price))
                        {
                            from.SendLocalizedMessage(1060398, m_Price.ToString());                             // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                            from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString());             // You have ~1_AMOUNT~ gold in cash remaining in your bank box.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1060020);                             // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing.
                            return;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1060019);                         // You decide against paying the healer, and thus remain dead.
                        return;
                    }
                }

                from.PlaySound(0x214);
                from.FixedEffect(0x376A, 10, 16);

                from.Resurrect();

                // adam: 3/18/08 - virtues are obsolete

                /*if ( m_Healer != null && from != m_Healer )
                 * {
                 *      VirtueLevel level = VirtueHelper.GetLevel( m_Healer, VirtueName.Compassion );
                 *
                 *      switch ( level )
                 *      {
                 *              case VirtueLevel.Seeker: from.Hits = AOS.Scale( from.HitsMax, 20 ); break;
                 *              case VirtueLevel.Follower: from.Hits = AOS.Scale( from.HitsMax, 40 ); break;
                 *              case VirtueLevel.Knight: from.Hits = AOS.Scale( from.HitsMax, 80 ); break;
                 *      }
                 * }*/

                Mobile m = from;

                Misc.Titles.AwardFame(from, -100, true);                 // TODO: Proper fame loss

                PlayerMobile pm = from as PlayerMobile;
                // If the player is an inmate of AI, we don't want them taking stat-loss
                // Adam: we now have gumps that don't invoke stat loss (m_Statloss)
                if (!Core.AOS && StatLossCandidate(from) && m_Statloss == true)
                {
                    double loss = (100.0 - (4.0 + (from.ShortTermMurders / 5.0))) / 100.0;                    //5 to 15% loss
                    if (loss < 0.85)
                    {
                        loss = 0.85;
                    }
                    else if (loss > 0.95)
                    {
                        loss = 0.95;
                    }

                    if (from.RawStr * loss > 10)
                    {
                        from.RawStr = (int)(from.RawStr * loss);
                    }
                    if (from.RawInt * loss > 10)
                    {
                        from.RawInt = (int)(from.RawInt * loss);
                    }
                    if (from.RawDex * loss > 10)
                    {
                        from.RawDex = (int)(from.RawDex * loss);
                    }

                    for (int s = 0; s < from.Skills.Length; s++)
                    {
                        if (from.Skills[s].Base * loss > 35)
                        {
                            from.Skills[s].Base *= loss;
                        }
                    }

                    //Pix: LOG it!!
                    try
                    {
                        Server.Commands.LogHelper lh = new Server.Commands.LogHelper("statloss.log");
                        lh.Log(Server.Commands.LogType.Mobile, pm, "Statloss was " + loss.ToString());
                        lh.Finish();
                    }
                    catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
                }
            }
        }
        public void Claim(Mobile from)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            bool claimed = false;
            int  stabled = 0;

            for (int i = 0; i < from.Stabled.Count; ++i)
            {
                BaseCreature pet = from.Stabled[i] as BaseCreature;

                if (pet == null)
                {
                    from.Stabled.RemoveAt(i);
                    --i;
                    continue;
                }

                if (pet.Deleted)
                {
                    pet.IsStabled            = false;
                    pet.LastStableChargeTime = DateTime.MinValue;                       // When set to MinValue, we don't serialize
                    from.Stabled.RemoveAt(i);
                    --i;
                    continue;
                }

                // tell the player they need to pay the back stable fees
                if (pet.GetFlag(CreatureFlags.StableHold))
                {
                    // charge the player back stable fees
                    if ((from.BankBox != null && from.BankBox.ConsumeTotal(typeof(Gold), pet.StableBackFees) == true))
                    {
                        Server.Commands.LogHelper Logger = new Server.Commands.LogHelper("PetHoldFromStables.log", false, true);
                        Logger.Log(string.Format("{0} gold was taken from {2}'s bank to cover late stable fees for {1}.", pet.StableBackFees, pet.Name, from));
                        Logger.Finish();

                        SayTo(from, "{0} gold was taken from your bank cover late stable fees for {1}.", pet.StableBackFees, pet.Name);
                        pet.StableBackFees = 0;
                        pet.SetFlag(CreatureFlags.StableHold, false);
                        goto add_pet;
                    }
                    else
                    {
                        SayTo(from, "You will need {0} gold in your bank to cover late stable fees for {1}.", pet.StableBackFees, pet.Name);
                        continue;
                    }
                }

add_pet:
                ++stabled;

                if ((from.Followers + pet.ControlSlots) <= from.FollowersMax)
                {
                    pet.SetControlMaster(from);

                    if (pet.Summoned)
                    {
                        pet.SummonMaster = from;
                    }

                    pet.ControlTarget = from;
                    pet.ControlOrder  = OrderType.Follow;

                    pet.MoveToWorld(from.Location, from.Map);

                    pet.IsStabled = false;
                    from.Stabled.RemoveAt(i);

                    pet.LastStableChargeTime = DateTime.MinValue;                       // When set to MinValue, we don't serialize
                    --i;

                    claimed = true;
                }
                else
                {
                    SayTo(from, 1049612, pet.Name);                     // ~1_NAME~ remained in the stables because you have too many followers.
                }
            }

            if (claimed)
            {
                SayTo(from, 1042559);                 // Here you go... and good day to you!
            }
            else if (stabled == 0)
            {
                SayTo(from, 502671);                 // But I have no animals stabled with me at the moment!
            }
        }
        public void BeginClaimList(Mobile from)
        {
            if (Deleted || !from.CheckAlive())
            {
                return;
            }

            ArrayList list = new ArrayList();

            for (int i = 0; i < from.Stabled.Count; ++i)
            {
                BaseCreature pet = from.Stabled[i] as BaseCreature;

                if (pet == null)
                {
                    from.Stabled.RemoveAt(i);
                    --i;
                    continue;
                }

                if (pet.Deleted)
                {
                    pet.IsStabled            = false;
                    pet.LastStableChargeTime = DateTime.MinValue;                       // When set to MinValue, we don't serialize
                    from.Stabled.RemoveAt(i);
                    --i;
                    continue;
                }

                // tell the player they need to pay the back stable fees
                if (pet.GetFlag(CreatureFlags.StableHold))
                {
                    // charge the player back stable fees
                    if ((from.BankBox != null && from.BankBox.ConsumeTotal(typeof(Gold), pet.StableBackFees) == true))
                    {
                        Server.Commands.LogHelper Logger = new Server.Commands.LogHelper("PetHoldFromStables.log", false, true);
                        Logger.Log(string.Format("{0} gold was taken from {2}'s bank to cover late stable fees for {1}.", pet.StableBackFees, pet.Name, from));
                        Logger.Finish();

                        SayTo(from, "{0} gold was taken from your bank cover late stable fees for {1}.", pet.StableBackFees, pet.Name);
                        pet.StableBackFees = 0;
                        pet.SetFlag(CreatureFlags.StableHold, false);
                        goto add_pet;
                    }
                    else
                    {
                        SayTo(from, "You will need {0} gold in your bank to cover late stable fees for {1}.", pet.StableBackFees, pet.Name);
                        continue;
                    }
                }

add_pet:
                list.Add(pet);
            }

            if (list.Count > 0)
            {
                from.SendGump(new ClaimListGump(this, from, list));
            }
            else
            {
                SayTo(from, 502671);                 // But I have no animals stabled with me at the moment!
            }
        }
Beispiel #5
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            try
            {
                // kill our timeout timer
                if (m_timeout != null)
                {
                    m_timeout.Stop();
                    m_timeout = null;
                }

                int      button = info.ButtonID;
                TimeSpan diff   = DateTime.Now - m_RTTLaunched;

                if (button == m_CorrectResponse + m_CorrectResponseOffset)
                {
                    // record answer
                    Server.Commands.LogHelper lh = new Server.Commands.LogHelper("RTT.log", false, true);
                    lh.Log(Server.Commands.LogType.Mobile, m_Mobile, string.Format("PASSED the RTT in {0} ms", diff.TotalMilliseconds));
                    lh.Finish();

                    m_Mobile.SendMessage("Thanks for verifying that you're at your computer.");
                    ((PlayerMobile)m_Mobile).RTTResult(true);

                    if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RTTNotifyEnabled))
                    {
                        if (diff <= TimeSpan.FromSeconds(1.0))
                        {
                            Server.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor,
                                                                             0x22,
                                                                             String.Format("{0}({1}) has quickly passed the RTT ({2} ms) ({3}).", m_Mobile.Name, m_Mobile.Serial, diff.TotalMilliseconds, m_strNotify));
                        }
                        else
                        {
                            Server.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor,
                                                                             0x482,
                                                                             String.Format("{0}({1}) has passed the RTT ({2} ms).  ({3})", m_Mobile.Name, m_Mobile.Serial, diff.TotalMilliseconds, m_strNotify));
                        }

                        // Look for and record suspiciously fast answers
                        if (diff <= TimeSpan.FromSeconds(3.0))
                        {
                            Server.Commands.LogHelper lh2 = new Server.Commands.LogHelper("RTTAlert.log", false, true);
                            lh2.Log(Server.Commands.LogType.Mobile, m_Mobile, string.Format("{0} ms", diff.TotalMilliseconds));
                            lh2.Finish();
                        }
                    }
                }
                else
                {
                    // record answer
                    Server.Commands.LogHelper lh = new Server.Commands.LogHelper("RTT.log", false, true);
                    lh.Log(Server.Commands.LogType.Mobile, m_Mobile, string.Format("FAILED the RTT in {0} ms", diff.TotalMilliseconds));
                    lh.Finish();

                    m_Mobile.SendMessage("You have failed the AFK test.");
                    ((PlayerMobile)m_Mobile).RTTResult(false);

                    if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RTTNotifyEnabled))
                    {
                        Server.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor,
                                                                         0x482,
                                                                         String.Format("{0}({1}) has failed the RTT. ({2})", m_Mobile.Name, m_Mobile.Serial, this.m_strNotify));
                    }
                }
            }
            catch (Exception e)
            {
                Server.Commands.LogHelper.LogException(e);
            }
        }