Exemplo n.º 1
0
        public override void OnMovement(Mobile m, Point3D oldLocation)
        {
            if (!m.Frozen && DateTime.UtcNow >= m_NextResurrect && InRange(m, 4) && !InRange(oldLocation, 4) && InLOS(m))
            {
                if (!m.Alive)
                {
                    m_NextResurrect = DateTime.UtcNow + ResurrectDelay;

                    if (m.Map == null || !m.Map.CanFit(m.Location, 16, false, false))
                    {
                        m.SendLocalizedMessage(502391);                           // Thou can not be resurrected there!
                    }
                    else if (CheckResurrect(m))
                    {
                        if (!CreaturePossession.IsInHouseOrBoat(m.Location, m.Map))
                        {
                            OfferResurrection(m);
                        }
                    }
                }
                else if (this.HealsYoungPlayers && m.Hits < m.HitsMax && m is PlayerMobile && ((PlayerMobile)m).Young)
                {
                    OfferHeal((PlayerMobile)m);
                }
            }
        }
Exemplo n.º 2
0
 public override void OnResponse(NetState sender, RelayInfo info)
 {
     if (sender != null)
     {
         Mobile from          = sender.Mobile;
         Button pressedButton = (Button)info.ButtonID;
         if (pressedButton == Button.Connect)
         {
             CreaturePossession.OnPossessTargetRequest(from);
             m_CurrentOwner.SendGump(this);
         }
         else if (pressedButton == Button.Disconnect)
         {
             if (from != null)
             {
                 if (!CreaturePossession.AttemptReturnToOriginalBody(from.NetState))
                 {
                     from.NetState.Dispose();
                 }
             }
         }
         else
         {
             m_CurrentOwner.SendGump(this);
         }
     }
 }
Exemplo n.º 3
0
 static void EventSink_Login(LoginEventArgs e)
 {
     if (e.Mobile != null && CreaturePossession.HasAnyPossessPermissions(e.Mobile.NetState))
     {
         e.Mobile.SendGump(new PossessGump(e.Mobile));
     }
 }
Exemplo n.º 4
0
        public void JoinZombieInstance(PlayerMobile player)
        {
            PlayerZombieProfile profile = ZombieEvent.EnsureProfile(player);
            ZombieAvatar        avatar  = profile.ZombieAvatar;

            profile.Active = true;
            if (avatar == null)
            {
                avatar = profile.CreateAvatar();
            }

            if (profile.ZombieSavePoint == Point3D.Zero && avatar != null &&
                DateTime.UtcNow > (profile.DisconnectTime + TimeSpan.FromMinutes(2)))
            {
                if (avatar.Backpack != null && avatar.Items.Count <= 1)
                {
                    avatar.EquipItem(new Dagger {
                        Speed = 1
                    });
                    avatar.Backpack.DropItem(new Bandage(7));
                    ZombieEvent.RandomClothing(avatar);
                }
                avatar.MoveToWorld(GetRandomLocation(), Map.ZombieLand);
            }

            CreaturePossession.ForcePossessCreature(null, player, avatar);

            if (avatar != null)
            {
                avatar.Blessed       = false;
                avatar.Hidden        = false;
                avatar.IgnoreMobiles = false;
                avatar.CantWalk      = false;
            }

            player.LogoutLocation = player.Location;
            player.Map            = Map.Internal;
            player.LogoutMap      = Map.Felucca;
        }
Exemplo n.º 5
0
        public static void ChatAction(NetState state, PacketReader pvSrc)
        {
            /*if ( !m_Enabled )
             *  return;
             */

            if (state == null || state.Mobile == null || state.Account == null)
            {
                return;
            }

            try
            {
                /*
                 * ChatUser user = ChatUser.GetChatUser( from );
                 *
                 * if ( user == null )
                 *  return;
                 */

                string lang     = pvSrc.ReadStringSafe(4);
                int    actionID = pvSrc.ReadInt16();
                string param    = pvSrc.ReadUnicodeString();

                /*
                 *              ChatActionHandler handler = ChatActionHandlers.GetHandler( actionID );
                 *
                 *              if ( handler != null )
                 *              {
                 *                      Channel channel = user.CurrentChannel;
                 *
                 *                      if ( handler.RequireConference && channel == null )
                 *                      {
                 *                              user.SendMessage( 31 ); // You must be in a conference to do this.
                 *                                                                              // To join a conference, select one from the Conference menu.
                 *                      }
                 *                      else if ( handler.RequireModerator && !user.IsModerator )
                 *                      {
                 *                              user.SendMessage( 29 ); // You must have operator status to do this.
                 *                      }
                 *                      else
                 *                      {
                 *                              handler.Callback( user, channel, param );
                 *                      }
                 *              }
                 *              else
                 *              {
                 *                      Console.WriteLine( "Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param );
                 *              }*/

                // CUSTOM CODE for uoforever--Chat b/w mobs with the same teamflags


                Mobile         from      = state.Mobile;
                List <XmlTeam> fromTeams = XmlAttach.GetTeams(from);
                if (fromTeams != null)
                {
                    List <NetState> states = NetState.Instances;
                    foreach (NetState nextstate in states)
                    {
                        if (nextstate.Mobile == null)
                        {
                            continue;
                        }
                        if (nextstate.Mobile.AccessLevel >= AccessLevel.GameMaster)
                        {
                            // just get the first team
                            nextstate.Mobile.SendMessage(101, "[" + fromTeams[0].TeamVal + "] " + from.Name + ": " + param);
                        }
                        else
                        {
                            if (nextstate.Mobile.CustomTeam)
                            {
                                List <XmlTeam> toTeams = XmlAttach.GetTeams(nextstate.Mobile);
                                if (XmlTeam.SameTeam(fromTeams, toTeams))
                                {
                                    nextstate.Mobile.SendMessage(101, from.Name + ": " + param);
                                }
                            }
                        }
                    }
                }
                else if (from.AccessLevel >= AccessLevel.Counselor ||
                         CreaturePossession.HasAnyPossessPermissions(from))
                {
                    List <NetState> states       = NetState.Instances;
                    Mobile          sourceMobile = from;
                    if (from is BaseCreature)
                    {
                        sourceMobile = state.Account.GetPseudoSeerLastCharacter();
                    }
                    if (sourceMobile != null)
                    {
                        foreach (NetState nextstate in states)
                        {
                            if (nextstate.Mobile == null)
                            {
                                continue;
                            }
                            if (nextstate.Mobile.AccessLevel >= AccessLevel.Counselor ||
                                CreaturePossession.HasAnyPossessPermissions(nextstate.Mobile))
                            {
                                // just get the first team
                                nextstate.Mobile.SendMessage(101, sourceMobile.Name + ": " + param);
                            }
                            else if (nextstate.Mobile is BaseCreature)
                            {
                                if (nextstate.Account == null)
                                {
                                    continue;
                                }
                                Mobile controllingMobile = nextstate.Account.GetPseudoSeerLastCharacter();
                                if (controllingMobile == null)
                                {
                                    continue;
                                }
                                nextstate.Mobile.SendMessage(101, sourceMobile.Name + ": " + param);
                            }
                        }
                    }
                }
                else if (from is BaseCreature)
                {
                    List <NetState> states            = NetState.Instances;
                    Mobile          controllingMobile = state.Account.GetPseudoSeerLastCharacter();
                    if (controllingMobile != null)
                    {
                        foreach (NetState nextstate in states)
                        {
                            if (nextstate.Mobile == null)
                            {
                                continue;
                            }
                            if (nextstate.Mobile.AccessLevel >= AccessLevel.Counselor ||
                                CreaturePossession.HasAnyPossessPermissions(nextstate.Mobile))
                            {
                                // just get the first team
                                nextstate.Mobile.SendMessage(101, controllingMobile.Name + ": " + param);
                            }
                            else if (nextstate.Mobile is BaseCreature)
                            {
                                nextstate.Mobile.SendMessage(101, controllingMobile.Name + ": " + param);
                            }
                        }
                    }
                }
                else
                {
                    from.SendMessage("You are not on a team!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 6
0
        public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance, bool success)
        {
            if (from.Alive && AllowGain(from /*, skill, amObj*/))
            {
                if (from.Skills.Cap > 0 && skill.Base < skill.Cap)
                {
                    if (skill.Base < 50.0)
                    {
                        Gain(from, skill);
                    }
                    else
                    {
                        double thirst = 20.0 - from.Thirst;
                        double hunger = 20.0 - from.Hunger;

                        double gc = 50.0;

                        if (skill.BaseFixedPoint >= 1200)
                        {
                            gc = 44;
                        }
                        else if (skill.BaseFixedPoint >= 1150)
                        {
                            gc = 42;
                        }
                        else if (skill.BaseFixedPoint >= 1100)
                        {
                            gc = 39;
                        }
                        else if (skill.BaseFixedPoint >= 1050)
                        {
                            gc = 37;
                        }
                        else if (skill.BaseFixedPoint >= 1000)
                        {
                            gc = 30;
                        }
                        else if (skill.BaseFixedPoint >= 900)
                        {
                            gc = 25;
                        }
                        else if (skill.BaseFixedPoint >= 800)
                        {
                            gc = 20;
                        }
                        else if (skill.BaseFixedPoint >= 700)
                        {
                            gc = 15;
                        }
                        else if (skill.BaseFixedPoint >= 600)
                        {
                            gc = 10;
                        }
                        else if (skill.BaseFixedPoint >= 500)
                        {
                            gc = 5;
                        }
                        else
                        {
                            gc = 2;
                        }

                        double gainmod = 0.0;

                        if (from is PlayerMobile)
                        {
                            gainmod = ((PlayerMobile)from).GetSkillGainModBonus(skill.SkillName);
                        }

                        double malus = skill.Info.GainFactor + (0.08 * (thirst / 20.0)) + (0.08 * (hunger / 20.0)) +
                                       (0.09 * (from.BAC / 60.0)) - gainmod;
                        // + (0.25 * (from.Skills.Total / from.Skills.Cap));

                        gc *= malus;

                        if (skill.Info.UsesDifficulty) // Base gain on success rate
                        {
                            if (success)
                            {
                                if (chance <= 0.65)
                                {
                                    gc /= 1.65 - chance; // changed to 2
                                }
                            }
                            else if (chance < 0.35)
                            {
                                gc *= 5.0 - chance; // chanced to 5
                            }
                        }

                        /*
                         * NO CHANGE in towns
                         * -25% in houses or boats
                         * +50% dungeons (not despise)
                         */

                        //GuardedRegion town = from.Region.GetRegion(typeof(GuardedRegion)) as GuardedRegion;

                        // NOTE currently CanBePenalized returns FALSE for crafting skills... that seems wrong
                        // i'm just using the CreaturePossession function here, no relation to pseudoseer system
                        if (CreaturePossession.IsInHouseOrBoat(from.Location, from.Map))
                        {
                            gc *= 1.25; // -25%
                        }
                        //if ( CanBePenalized( skill.SkillName ) && town != null && !town.IsDisabled() )
                        //	gc *= 2.25;
                        //else
                        //{

                        var dungeon = from.Region.GetRegion(typeof(DungeonRegion)) as DungeonRegion;
                        if (dungeon != null)
                        {
                            gc *= 0.50;
                        }
                        //}

                        if (FactionObelisks.Obelisks != null && from is PlayerMobile)
                        {
                            var p    = from as PlayerMobile;
                            var acct = p.Account as Account;
                            foreach (var obelisk in FactionObelisks.Obelisks)
                            {
                                if (obelisk.ObeliskType == ObeliskType.SkillGain && !String.IsNullOrEmpty(obelisk.OwningFaction) && acct != null)
                                {
                                    if (obelisk.ObeliskUsers != null && obelisk.ObeliskUsers.ContainsKey(acct))
                                    {
                                        gc *= 0.95;
                                        break;
                                    }
                                }
                            }
                        }

                        if (from is ZombieAvatar)
                        {
                            if (skill.SkillName == SkillName.Archery || skill.SkillName == SkillName.Fencing ||
                                skill.SkillName == SkillName.Hiding || skill.SkillName == SkillName.Stealth || skill.SkillName == SkillName.Macing ||
                                skill.SkillName == SkillName.Parry || skill.SkillName == SkillName.Swords ||
                                skill.SkillName == SkillName.Tactics || skill.SkillName == SkillName.Anatomy ||
                                skill.SkillName == SkillName.Magery || skill.SkillName == SkillName.EvalInt)
                            {
                                gc *= ZombieEvent.CSOptions.MeleeMod;
                            }
                        }

                        if (gc > 60)
                        {
                            gc = 30;
                        }

                        var bc = from as BaseCreature;

                        /*if (bc != null)
                         *                      {
                         *                              if (bc.Controlled)
                         *                              {
                         *                                      if (bc.IsBonded)
                         *                                      {
                         *                                              gc /= 1.5;
                         *                                      }
                         *                              }
                         *
                         *                              gc /= bc.SkillGainMultiplier; // can customize how well they gain
                         *                      }*/

                        // Dynamic control of all skill gain
                        gc /= DynamicSettingsController.SkillGainMultiplier;

                        //from.SendMessage( "Gain Chance: 1/{0}", gc );
                        if ((1.0 / gc) > Utility.RandomDouble())
                        {
                            Gain(from, skill);
                        }
                        if (0.025 > Utility.RandomDouble())
                        {
                            GainStat(from, skill);
                        }
                    }
                }
                else if (success && 0.25 > Utility.RandomDouble())
                {
                    GainStat(from, skill);
                }
            }

            return(success);
        }