Пример #1
0
 public bool GetRandomMapPosition(ref Point pRet)
 {
     try
     {
         pRet = m_pValidTiles[ThreadSafeRandom.RandGet(m_pValidTiles.Count) % m_pValidTiles.Count];
         if (m_pMap[pRet.X, pRet.Y].Access != TileType.AVAILABLE)
         {
             return(false);
         }
         if (m_pMap.QueryRegion(7, (ushort)pRet.X, (ushort)pRet.Y))
         {
             return(false);
         }
         if (m_pMap.QueryRegion(8, (ushort)pRet.X, (ushort)pRet.Y))
         {
             return(false);
         }
         if (m_pMap.QueryRole((ushort)pRet.X, (ushort)pRet.Y) != null)
         {
             return(false);
         }
         //Console.WriteLine("Random Flag Pos Generated x({0}),y({1})", pRet.X, pRet.Y);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #2
0
        public void OnFinish()
        {
            ushort[] m_startX = { 430, 423, 439, 428, 452, 464, 439 };
            ushort[] m_startY = { 378, 394, 384, 365, 365, 378, 396 };

            foreach (var usr in _getUserScores.OrderByDescending(x => x.Points))
            {
                Client client;
                if (!ServerKernel.Players.TryGetValue(usr.Identity, out client) || client.Character == null)
                {
                    continue;
                }

                Character plr = client.Character;

                plr.ChangeMap(m_startX[ThreadSafeRandom.RandGet() % 7], m_startY[ThreadSafeRandom.RandGet() % 7], 1002);

                switch (GetRank(plr.Identity))
                {
                case 1:
                    plr.AwardMoney(3000000);
                    plr.AwardEmoney(1000);
                    ServerKernel.SendMessageToAll(
                        string.Format(
                            "Congratulations! {0} has won the Score PK Tournament and awarded 3,000,000 silvers and 1,000 CPs.",
                            plr.Name), ChatTone.TALK);
                    break;

                case 2:
                    plr.AwardMoney(2000000);
                    plr.AwardEmoney(500);
                    ServerKernel.SendMessageToAll(
                        string.Format(
                            "{0} has got second place in the Score PK Tournament and awarded 2,000,000 silvers and 500 CPs.",
                            plr.Name), ChatTone.TALK);
                    break;

                case 3:
                    plr.AwardMoney(1000000);
                    plr.AwardEmoney(250);
                    ServerKernel.SendMessageToAll(
                        string.Format(
                            "{0} has got third place in the Score PK Tournament and awarded 1,000,000 silvers and 250 CPs.",
                            plr.Name), ChatTone.TALK);
                    break;

                default:
                    plr.AwardMoney(100000);
                    plr.AwardEmoney(100);
                    plr.Send(
                        "You awarded 100,000 silvers and 100 CPs for participating the Score PK Tournament.");
                    break;
                }
            }

            m_pState = EventState.ENDED;
        }
Пример #3
0
        public Item GeneratePickUp(Character pPicker)
        {
            lock (m_pSyncRoot)
            {
                if (m_bTaken)
                {
                    return(null);
                }

                m_bTaken = true;

                m_pItem                   = new Item(pPicker);
                m_pItem.Type              = m_pItemtype.Type;
                m_pItem.OwnerIdentity     = m_idOwner;
                m_pItem.PlayerIdentity    = pPicker.Identity;
                m_pItem.Durability        = (ushort)(m_pItemtype.Amount / 60);
                m_pItem.MaximumDurability = (ushort)(m_pItemtype.AmountLimit + m_nDura);
                m_pItem.Color             = (ItemColor)ThreadSafeRandom.RandGet(2, 9);

                if (m_pItem.Durability > 1)
                {
                    const int nRate = 50;
                    if (Calculations.ChanceCalc(nRate))
                    {
                        m_pItem.Durability = (ushort)(m_pItem.Durability * (ThreadSafeRandom.RandGet(15) + 20) / 100);
                    }
                    else
                    {
                        m_pItem.Durability = (ushort)(m_pItem.Durability * (ThreadSafeRandom.RandGet(15) + 35) / 100);
                    }

                    m_pItem.Durability = Calculations.CutTrail((ushort)1, m_pItem.Durability);
                }

                m_pItem.Position = ItemPosition.FLOOR;

                m_pItem.SocketOne = (SocketGem)m_pItemtype.Gem1;
                m_pItem.SocketTwo = (SocketGem)m_pItemtype.Gem2;
                m_pItem.Effect    = (ItemEffect)m_pItemtype.Magic1;

                if (m_nPlus > 0)
                {
                    m_pItem.Plus = m_nPlus;
                }
                else
                {
                    m_pItem.Plus = m_pItemtype.Magic3;
                }

                if (m_nDmg > 0 && (m_pItem.IsEquipment() || m_pItem.IsWeapon()))
                {
                    m_pItem.ReduceDamage = m_nDmg;
                }
                return(m_pItem);
            }
        }
        public MsgUsrLogin(uint dwUserId, uint dwPacketHash)
            : base(PacketType.LOGIN_REQUEST_USER_SIGNIN, 72, 64)
        {
            RequestTime  = (uint)UnixTimestamp.Timestamp();
            UserIdentity = dwUserId;
            PacketHash   = dwPacketHash;

            for (int i = 36; i < 64; i++)
            {
                WriteByte((byte)ThreadSafeRandom.RandGet(1, 255), i);
            }
        }
        /// <summary>
        /// This constructor builds the packet ready to be sent.
        /// </summary>
        /// <param name="szName">The username that will authenticate the Msg Server with the Login Server.</param>
        /// <param name="szPass">The password that will authenticate the Msg Server with the Login Server.</param>
        /// <param name="szServerName">The server name, so the LoginServer will be enabled to redirect the player to the right game server.</param>
        /// <param name="usMaxOnline">The max amount of players enabled on this server.</param>
        public MsgLoginSvAuthentication(string szName, string szPass, string szServerName, ushort usMaxOnline)
            : base(PacketType.LOGIN_AUTH_CONFIRM, 512, 504)
        {
            for (int i = 4; i < Length; i++)
            {
                WriteByte((byte)ThreadSafeRandom.RandGet(1, 254), i);
            }

            Username         = szName.Substring(0, szName.Length > _SERVER_NAME_MAX_LENGTH ? _USERNAME_MAX_LENGTH - 1 : szName.Length);
            Password         = szPass.Substring(0, szPass.Length > _PASSWORD_MAX_LENGTH ? _PASSWORD_MAX_LENGTH - 1 : szPass.Length);
            ServerName       = szServerName.Substring(0, szServerName.Length > _PASSWORD_MAX_LENGTH ? _PASSWORD_MAX_LENGTH - 1 : szServerName.Length);
            MaxOnlinePlayers = usMaxOnline;
        }
Пример #6
0
        /// <summary>
        /// Writes the message to the packet.
        /// </summary>
        /// <param name="helloMsg">The message should have 16 characters at max.</param>
        /// <param name="nMessageOffset">A value from 12 to 1000.</param>
        public MsgLoginSvAuthRequest(string helloMsg, int nMessageOffset = 48)
            : base(PacketType.LOGIN_AUTH_REQUEST, 1024, 1016)
        {
            for (int i = 4; i < Length; i++)
            {
                if (i < 8 || i > 11)
                {
                    WriteByte((byte)ThreadSafeRandom.RandGet(1, 254), i);
                }
            }

            MessageOffset = nMessageOffset;
            Message       = helloMsg.Substring(0, _MESSAGE_LENGTH);
        }
Пример #7
0
 public void Generate()
 {
     Value1 = ThreadSafeRandom.RandGet(0, 10);
     Value2 = ThreadSafeRandom.RandGet(0, 10);
     if (Calculations.ChanceCalc(50f))
     {
         Result = Value1 + Value2;
     }
     else
     {
         long temp = Value1 + Value2;
         Result = (Value1 + Value2) * (ThreadSafeRandom.RandGet(7, 12) / 100);
     }
     Message = "Hello! If you don't reply this captcha or give the wrong answer, you will be disconnected! " +
               string.Format("So, answer me OK if this equation is correct or Cancel if not. {0}+{1}={2}", Value1,
                             Value2, Result);
 }
Пример #8
0
        public void WatchMatch(Character watcher, uint idRole)
        {
            ArenaMatch match = FindUser(idRole);

            if (match == null) // match doesn't exist
            {
                return;
            }

            if (FindUser(watcher.Identity) != null) // can't watch, already fighting
            {
                return;
            }

            if (match.Identity1 == watcher.Identity ||
                match.Identity2 == watcher.Identity)    // user is one of the players (might not happen)
            {
                return;
            }

            if (!match.IsRunning()) // fight has ended
            {
                return;
            }

            if (watcher.Map.IsRecordDisable())
            {
                uint  dwMapId = watcher.RecordMapIdentity;
                Point pos     = new Point(watcher.RecordMapX, watcher.RecordMapY);

                watcher.Map.GetRebornMap(ref dwMapId, ref pos);
                watcher.SetRecordPos(dwMapId, (ushort)pos.X, (ushort)pos.Y);
            }
            else
            {
                watcher.SetRecordPos(watcher.MapIdentity, watcher.MapX, watcher.MapY);
            }
            //match.Map.AddClient(watcher);
            watcher.ChangeMap((ushort)ThreadSafeRandom.RandGet(35, 70),
                              (ushort)ThreadSafeRandom.RandGet(35, 70), match.Map.Identity);

            match.SendToMap();
        }
Пример #9
0
        public void ProcessMsgAuth(Client pClient, byte[] pMsg)
        {
            if (pClient != null && pClient.Packet != null) // check if it's alright
            {
                byte[] pPacket = pClient.Packet;
                var    pType   = (PacketType)BitConverter.ToInt16(pPacket, 2);

                if (BitConverter.ToUInt16(pPacket, 0) == 276 &&
                    (pType == PacketType.MSG_ACCOUNT1))
                {
                    var pRequest = new MsgAccount(pPacket, pClient.IpAddress.GetHashCode());

                    // tells the console that the user x is trying to login on server y
                    ServerKernel.Log.SaveLog(string.Format("User [{0}] is trying to login on server [{1}].",
                                                           pClient.Account, pRequest.Server), false, "Login_Server");

                    // let's check if user is spamming login requests
                    LoginAttemptRecord pLogin = null;
                    if (!ServerKernel.LoginAttemptRecords.TryGetValue(pClient.IpAddress, out pLogin))
                    {
                        pLogin = new LoginAttemptRecord(pClient.IpAddress);
                        ServerKernel.LoginAttemptRecords.TryAdd(pLogin.IpAddress, pLogin);
                    }

                    if (!pLogin.Enabled) // user spamming login?
                    {
                        pClient.Send(new MsgConnectEx(RejectionType.MAXIMUM_LOGIN_ATTEMPTS));
                        ServerKernel.Log.SaveLog(
                            string.Format("User [{0}] has passport denied due to exceeding login limit on IP [{1}].",
                                          pRequest.Account, pClient.IpAddress), true, "Login_Server");
                        pClient.Disconnect();
                        return;
                    }

                    DbAccount pUser = new AccountRepository().SearchByName(pRequest.Account); // fetch user information
                    if (pUser != null)                                                        // user exists?
                    {
                        // yes
                        pClient.Account = pUser;

                        // check uncommon characters
                        var szPw = string.Empty;
                        foreach (var c in pRequest.Password)
                        {
                            switch (c)
                            {
                            case '-':
                                szPw += '0';
                                break;

                            case '#':
                                szPw += '1';
                                break;

                            case '(':
                                szPw += '2';
                                break;

                            case '"':
                                szPw += '3';
                                break;

                            case '%':
                                szPw += '4';
                                break;

                            case '\f':
                                szPw += '5';
                                break;

                            case '\'':
                                szPw += '6';
                                break;

                            case '$':
                                szPw += '7';
                                break;

                            case '&':
                                szPw += '8';
                                break;

                            case '!':
                                szPw += '9';
                                break;

                            default:
                                szPw += c;
                                break;
                            }
                        }

                        bool bSuccess = true;
                        // check if user has input the right password
                        if (pUser.Password != WhirlpoolHash.Hash(szPw))
                        {
                            // invalid pw
                            pClient.Send(new MsgConnectEx(RejectionType.INVALID_PASSWORD));
                            ServerKernel.Log.SaveLog(
                                string.Format("User [{0}] entered an invalid password [{1}].", pUser.Username,
                                              pClient.IpAddress), true, "LoginServer");
                            pClient.Disconnect();
                            return;
                        }

                        if (pUser.Lock > 0) // user is banned?
                        {
                            if (pUser.Lock >= 3 || pUser.LockExpire == 0 || UnixTimestamp.Timestamp() < pUser.LockExpire)
                            {
                                // banned
                                pClient.Send(new MsgConnectEx(RejectionType.ACCOUNT_BANNED));
                                ServerKernel.Log.SaveLog(
                                    string.Format("User [{0}] has passport denied due to account lock status.",
                                                  pUser.Username), true, "LoginServer");
                                pClient.Disconnect();
                                return;
                            }
                        }

                        //if (pUser.Lock == 2) // user has activated account?
                        //{
                        //    pClient.Send(new MsgConnectEx(RejectionType.ACCOUNT_NOT_ACTIVATED));
                        //    ServerKernel.Log.SaveLog(
                        //        string.Format("User [{0}] has passport denied due to account inactive status.",
                        //            pUser.Username), true, "LoginServer");

                        //    pClient.Disconnect();
                        //    return;
                        //}

                        // temporary just to leave people join using any server
                        GameServer pServer = ServerKernel.OnlineServers.Values.FirstOrDefault();
                        if (pServer == null)//!ServerKernel.OnlineServers.TryGetValue(pRequest.Server, out pServer))
                        // server is not online
                        {
                            pClient.Send(new MsgConnectEx(RejectionType.SERVER_MAINTENANCE));
                            ServerKernel.Log.SaveLog(
                                string.Format("User [{0}] tried to login on a invalid server [{1}].", pUser.Username,
                                              pRequest.Server), true, "LoginServer");

                            pClient.Disconnect();
                            return;
                        }

                        uint dwHash = (uint)ThreadSafeRandom.RandGet(1000, int.MaxValue);

                        var pTransferCipher = new TransferCipher(ServerKernel.LoginTransferKey,
                                                                 ServerKernel.LoginTransferSalt, pClient.IpAddress);
                        var pCrypto = pTransferCipher.Encrypt(new[] { pUser.Identity, dwHash });

                        string szAddress = "135.12.15.139"; // random ip just to connect
                        if (!pServer.IpAddress.StartsWith("127") && pServer.IpAddress != "localhost")
                        {
                            szAddress = pServer.IpAddress;
                        }

                        pServer.Send(new MsgUsrLogin(pUser.Identity, dwHash)
                        {
                            IpAddress = pClient.IpAddress
                        });

                        pClient.Send(new MsgConnectEx(pCrypto[0], pCrypto[1], szAddress, 5816));
                        ServerKernel.Log.SaveLog(string.Format("User [{0}] has successfully logged into {1}({2}:{3}).",
                                                               pUser.Username, pRequest.Server, szAddress, pServer.GamePort), true, "Login_Server", LogType.MESSAGE);

                        pUser.LastLogin = UnixTimestamp.Timestamp();
                        new AccountRepository().SaveOrUpdate(pUser);
                        return;
                    }
                    else
                    {
                        // no
                        pClient.Send(new MsgConnectEx(RejectionType.INVALID_PASSWORD));
                        ServerKernel.Log.SaveLog(
                            string.Format("User [{0}] doesn't exist. Connection [{1}].", pRequest.Account,
                                          pClient.IpAddress), true, "Login_Server");
                    }
                }
                else
                {
                    pClient.Send(new MsgConnectEx(RejectionType.INVALID_AUTHENTICATION_PROTOCOL));
                    ServerKernel.Log.SaveLog(string.Format("User has tried to connect with an invalid protocol at {0}.", pClient.IpAddress));
                }

                pClient.Disconnect();
            }
        }
 public void GetRebornPos(out Point pos)
 {
     pos   = new Point();
     pos.X = (ushort)ThreadSafeRandom.RandGet(35, 70);
     pos.Y = (ushort)ThreadSafeRandom.RandGet(35, 70);
 }
        public int CalcAttackPower(IRole attacker, IRole attacked, ref InteractionEffect pSpecial)
        {
            if (attacked is Character)
            {
                Character pUser = attacked as Character;
                if (pUser.QueryTransformation != null && pUser.QueryTransformation.Lookface == 223)
                {
                    return(1);
                }
            }

            if (m_pOwner.Map.IsLineSkillMap())
            {
                return(1);
            }

            if (attacked.QueryStatus(FlagInt.VORTEX) != null)
            {
                return(1);
            }

            int nAttack = 0;

            if (Calculations.ChanceCalc(50))
            {
                nAttack = attacker.MaxAttack - ThreadSafeRandom.RandGet(1, Math.Max(1, attacker.MaxAttack - attacker.MinAttack) / 2 + 1);
            }
            else
            {
                nAttack = attacker.MinAttack + ThreadSafeRandom.RandGet(1, Math.Max(1, attacker.MaxAttack - attacker.MinAttack) / 2 + 1);
            }

            if (attacker is Character && attacked is Character && (attacker as Character).IsBowman())
            {
                nAttack = (int)(nAttack / 1.5f);
            }

            // handle physical status
            if (attacker.QueryStatus(FlagInt.STIG) != null)
            {
                float tPower = attacker.QueryStatus(FlagInt.STIG).Power;
                if (tPower > 30000)
                {
                    tPower  = (tPower - 30000) / 100f;
                    nAttack = (int)(nAttack * tPower);
                }
                else
                {
                    nAttack += (short)tPower;
                }
            }

            int nRawDefense = attacked.Defense;
            int nDef        = attacked.AdjustDefense(nRawDefense);

            if (attacker.QueryStatus(FlagInt.OBLIVION) != null &&
                !(attacked is Character) &&
                ((attacked is Monster) && !(attacked as Monster).IsBoss))
            {
                nAttack *= 2;
            }

            if (attacker.QueryStatus(FlagInt.FATAL_STRIKE) != null &&
                ((!attacked.IsDynaNpc() && !(attacked is Character))))
            {
                float tPower = attacker.QueryStatus(FlagInt.FATAL_STRIKE).Power;
                if (tPower > 30000)
                {
                    tPower  = (tPower - 30000) / 100f;
                    nAttack = (int)(nAttack * tPower);
                }
                else
                {
                    nAttack += (short)tPower;
                }

                if (attacked is Monster)
                {
                    Monster pMob = attacked as Monster;
                    if (pMob.IsGuard())
                    {
                        nAttack /= 10;
                    }
                }
            }

            if (attacker.QueryStatus(FlagInt.VORTEX) != null && !attacked.IsDynaNpc() && !(attacked is Character))
            {
                float tPower = attacker.QueryStatus(FlagInt.VORTEX).Power;
                if (tPower > 30000)
                {
                    tPower  = (tPower - 30000) / 100f;
                    nAttack = (int)(nAttack * tPower);
                }
                else
                {
                    nAttack += (short)tPower;
                }
            }

            if (attacker.QueryStatus(FlagInt.SUPERMAN) != null &&
                (!attacked.IsDynaNpc() && !(attacked is Character)))
            {
                float tPower = attacker.QueryStatus(FlagInt.SUPERMAN).Power;
                if (tPower > 30000)
                {
                    tPower  = (tPower - 30000) / 100f;
                    nAttack = (int)(nAttack * tPower);
                }
                else
                {
                    nAttack += (short)tPower;
                }
            }

            if (attacked.QueryStatus(FlagInt.SHIELD) != null)
            {
                float tPower = attacked.QueryStatus(FlagInt.SHIELD).Power;
                if (tPower > 30000)
                {
                    tPower = (tPower - 30000) / 100f;
                    nDef   = (int)(nDef * tPower);
                }
                else
                {
                    nDef += (short)tPower;
                }
            }

            if (attacker.Magics.QueryMagic() != null)
            {
                float tPower = attacker.Magics.QueryMagic().QueryPower();
                if (tPower > 30000)
                {
                    tPower  = (tPower - 30000) / 100f;
                    nAttack = (int)(nAttack * tPower);
                }
                else
                {
                    nAttack += (short)tPower;
                }
            }

            //float reduction = attacked.GetReduceDamage();
            int   nDamage = (int)((nAttack - nDef) * (1f - (attacked.GetReduceDamage() / 100f)));
            float tort    = (attacked.GetTortoiseGemEffect() / 100f);

            nDamage = (int)(nDamage * (1f - tort));

            if (nDamage <= 0)
            {
                nDamage = 7;
            }

            if (attacker is Character && attacked.IsMonster())
            {
                nDamage = CalcDamageUser2Monster(nAttack, nDef, attacker.Level, attacked.Level);
                nDamage = attacked.AdjustWeaponDamage(nDamage);
                nDamage = AdjustMinDamageUser2Monster(nDamage, attacker, attacked);
            }
            else if (attacker.IsMonster() && attacked is Character)
            {
                nDamage = CalcDamageMonster2User(nAttack, nDef, attacker.Level, attacked.Level);
                nDamage = attacked.AdjustWeaponDamage(nDamage);
                nDamage = AdjustMinDamageMonster2User(nDamage, attacker, attacked);
            }
            else
            {
                nDamage = attacked.AdjustWeaponDamage(nDamage);
            }

            //if (attacker is Character && attacked is Character && attacker.BattlePower < attacked.BattlePower)
            //{
            //    nDamage /= 2;
            //}

            #region Block, Critical, Break
            if (attacker.BattlePower < attacked.BattlePower)
            {
                if (attacked is Character)
                {
                    // Break (Pene is on the magic code)
                    // Break through the battle power cap...
                    // If the break fails, the damage is reduced by half.
                    if (attacked.Counteraction < attacker.Breakthrough)
                    {
                        if (!Calculations.ChanceCalc((float)(attacker.Breakthrough - attacked.Counteraction) / 10))
                        {
                            nDamage /= 2;
                        }
                        else
                        {
                            pSpecial |= InteractionEffect.BREAKTHROUGH;
                        }
                        //Owner.SendMessage(string.Format("Break: {0} Counter: {1} Difference: {2}%", GetBreakthrough(), pTarget.GetCounteraction(), (float)(GetBreakthrough() - pTarget.GetCounteraction()) / 10));
                    }
                    else
                    {
                        nDamage /= 2;
                    }
                }
            }

            // Critical is enabled on every monster. :)
            // Multiply the damage by 1.5
            if (attacker.CriticalStrike > attacked.Immunity)
            {
                if (Calculations.ChanceCalc((float)(attacker.CriticalStrike - attacked.Immunity) / 100))
                {
                    nDamage   = (int)(nDamage * 1.5f);
                    pSpecial |= InteractionEffect.CRITICAL_STRIKE;
                }
            }

            if (attacked.Block > 0 && Calculations.ChanceCalc((float)attacked.Block / 100))
            {
                nDamage  /= 10;
                pSpecial |= InteractionEffect.BLOCK;
            }

            if (QueryMagic() != null && QueryMagic().GetElement() > ElementType.NONE)
            {
                switch (QueryMagic().GetElement())
                {
                case ElementType.WATER:
                    pSpecial |= InteractionEffect.WATER_RESIST;
                    break;

                case ElementType.FIRE:
                    pSpecial |= InteractionEffect.FIRE_RESIST;
                    break;

                case ElementType.WOOD:
                    pSpecial |= InteractionEffect.WOOD_RESIST;
                    break;

                case ElementType.METAL:
                    pSpecial |= InteractionEffect.METAL_RESIST;
                    break;

                case ElementType.EARTH:
                    pSpecial |= InteractionEffect.EARTH_RESIST;
                    break;
                }
            }
            #endregion

            if (attacker is Monster && QueryMagic() != null && QueryMagic().GetElement() > ElementType.NONE)
            {
                switch (QueryMagic().GetElement())
                {
                case ElementType.WATER:
                {
                    nDamage = (int)(nDamage * (1 - (attacked.WaterResistance / 100f)));
                    break;
                }

                case ElementType.FIRE:
                {
                    nDamage = (int)(nDamage * (1 - (attacked.FireResistance / 100f)));
                    break;
                }

                case ElementType.EARTH:
                {
                    nDamage = (int)(nDamage * (1 - (attacked.EarthResistance / 100f)));
                    break;
                }

                case ElementType.WOOD:
                {
                    nDamage = (int)(nDamage * (1 - (attacked.WoodResistance / 100f)));
                    break;
                }

                case ElementType.METAL:
                {
                    nDamage = (int)(nDamage * (1 - (attacked.MetalResistance / 100f)));
                    break;
                }
                }
            }

            if (attacker is Character)
            {
                nDamage += attacker.AddFinalAttack;
            }

            if (attacked is Character)
            {
                nDamage -= attacked.AddFinalDefense;
            }

            if (attacked is Monster)
            {
                nDamage = (int)Math.Min(nDamage, attacked.MaxLife * 700);
            }

            if (nDamage <= 0)
            {
                nDamage = 1;
            }

            return(nDamage);
        }
Пример #12
0
        public void Start()
        {
            m_tStartup.Startup(10);
            m_pStatus = ArenaStatus.NOT_STARTED;

            m_pPlayer1.DetachBadlyStatus(m_pPlayer1);
            m_pPlayer2.DetachBadlyStatus(m_pPlayer2);

            //Console.WriteLine("Players {0} vs {1} has been sent to map {2}", m_pPlayer1.Name, m_pPlayer2.Name, m_pMap.Identity);

            if (m_pPlayer1.Map.IsRecordDisable())
            {
                uint  dwMapId = m_pPlayer1.RecordMapIdentity;
                Point pos     = new Point(m_pPlayer1.RecordMapX, m_pPlayer1.RecordMapY);

                m_pPlayer1.Map.GetRebornMap(ref dwMapId, ref pos);
                m_pPlayer1.SetRecordPos(dwMapId, (ushort)pos.X, (ushort)pos.Y);
            }
            else
            {
                m_pPlayer1.SetRecordPos(m_pPlayer1.MapIdentity, m_pPlayer1.MapX, m_pPlayer1.MapY);
            }

            if (m_pPlayer2.Map.IsRecordDisable())
            {
                uint  dwMapId = m_pPlayer2.RecordMapIdentity;
                Point pos     = new Point(m_pPlayer2.RecordMapX, m_pPlayer2.RecordMapY);

                m_pPlayer2.Map.GetRebornMap(ref dwMapId, ref pos);
                m_pPlayer2.SetRecordPos(dwMapId, (ushort)pos.X, (ushort)pos.Y);
            }
            else
            {
                m_pPlayer2.SetRecordPos(m_pPlayer2.MapIdentity, m_pPlayer2.MapX, m_pPlayer2.MapY);
            }

            if (!m_pPlayer1.IsAlive)
            {
                m_pPlayer1.Reborn(false, true);
            }
            if (!m_pPlayer2.IsAlive)
            {
                m_pPlayer2.Reborn(false, true);
            }

            try
            {
                m_pPlayer1.ChangeMap((ushort)ThreadSafeRandom.RandGet(35, 70),
                                     (ushort)ThreadSafeRandom.RandGet(35, 70), m_pMap.Identity);
            }
            catch
            {
                Finish(m_pPlayer2, m_pPlayer1, true);
                return;
            }
            try
            {
                m_pPlayer2.ChangeMap((ushort)ThreadSafeRandom.RandGet(35, 70),
                                     (ushort)ThreadSafeRandom.RandGet(35, 70), m_pMap.Identity);
            }
            catch
            {
                Finish(m_pPlayer1, m_pPlayer2, true);
                return;
            }

            SendToMap();

            m_pPkMode1 = m_pPlayer1.PkMode;
            m_pPkMode2 = m_pPlayer2.PkMode;

            m_pPlayer1.PkMode = PkModeType.PK_MODE;
            m_pPlayer2.PkMode = PkModeType.PK_MODE;

            m_pPlayer1.SendArenaInformation(m_pPlayer2);
            m_pPlayer2.SendArenaInformation(m_pPlayer1);

            MsgQualifyingInteractive pMsg = new MsgQualifyingInteractive();

            pMsg.Type   = ArenaType.MATCH;
            pMsg.Option = 5; // Match On
            m_pPlayer1.Send(pMsg);
            m_pPlayer2.Send(pMsg);

            m_pPlayer1.DetachStatus(FlagInt.RIDING);
            m_pPlayer2.DetachStatus(FlagInt.RIDING);

            m_pPlayer1.FillLife();
            m_pPlayer1.FillMana();
            m_pPlayer2.FillLife();
            m_pPlayer2.FillMana();
        }
Пример #13
0
 public void GetRebornPos(out Point pos)
 {
     pos   = new Point();
     pos.X = m_pTpX[ThreadSafeRandom.RandGet(0, m_pTpX.Length) % m_pTpX.Length];
     pos.Y = m_pTpY[ThreadSafeRandom.RandGet(0, m_pTpY.Length) % m_pTpY.Length];
 }