Пример #1
0
        /// <summary>
        /// Handles a warp request from a client
        /// </summary>
        static public void Warp(Helpers.ResetFlags flags, Player player, IEnumerable <LioInfo.WarpField> warpGroup, int invulnTime)
        {               //Search for valid warps to use
                        //List<LioInfo.WarpField> valid = new List<LioInfo.WarpField>();
            List <Arena.RelativeObj> valid = new List <Arena.RelativeObj>();

            Arena.RelativeObj unassignedEscape = null;

            foreach (LioInfo.WarpField warp in warpGroup)
            {                   //Do we have the appropriate skills?
                if (!Logic_Assets.SkillCheck(player, warp.WarpFieldData.SkillLogic))
                {
                    continue;
                }
                //Test for viability
                int playerCount = player._arena.PlayerCount;

                if (warp.WarpFieldData.MinPlayerCount > playerCount)
                {
                    continue;
                }
                if (warp.WarpFieldData.MaxPlayerCount < playerCount)
                {
                    continue;
                }

                //Specific team warp but we're on the wrong team
                if (warp.WarpFieldData.WarpMode == LioInfo.WarpField.WarpMode.SpecificTeam &&
                    player._team._id != warp.WarpFieldData.WarpModeParameter)
                {
                    continue;
                }
                List <Arena.RelativeObj> spawnPoints;
                if (warp.GeneralData.RelativeId != 0)
                {   //Search for possible points to warp from
                    spawnPoints = player._arena.findRelativeID(warp.GeneralData.HuntFrequency, warp.GeneralData.RelativeId, player);
                    if (spawnPoints == null)
                    {
                        continue;
                    }
                }
                else
                {   //Fake it to make it
                    spawnPoints = new List <Arena.RelativeObj> {
                        new Arena.RelativeObj(warp.GeneralData.OffsetX, warp.GeneralData.OffsetY, 0)
                    };
                }
                foreach (Arena.RelativeObj point in spawnPoints)
                {   //Check player concentration
                    playerCount = player._arena.getPlayersInBox(
                        point.posX, point.posY,
                        warp.GeneralData.Width, warp.GeneralData.Height).Count;

                    if (warp.WarpFieldData.MinPlayersInArea > playerCount)
                    {
                        continue;
                    }
                    if (warp.WarpFieldData.MaxPlayersInArea < playerCount)
                    {
                        continue;
                    }
                    point.warp = warp;

                    if (warp.WarpFieldData.WarpMode == LioInfo.WarpField.WarpMode.Unassigned)
                    {   //TODO find uses of this
                        unassignedEscape = point;
                        break;
                    }
                    valid.Add(point);
                }
            }

            if (valid.Count == 0)
            {                   //Do we have an unassigned escape?
                if (unassignedEscape != null)
                {
                    //Great! Use this
                    valid.Add(unassignedEscape);
                }
                else
                {                       //We found nuttin'
                    Log.write(TLog.Warning, "Unable to satisfy warpgroup for {0}.", player);
                    return;
                }
            }

            if (valid.Count == 1)
            {
                Warp(flags, player, valid[0], invulnTime);
            }
            else if (valid.Count > 1)
            {
                Warp(flags, player, valid[player._arena._rand.Next(0, valid.Count)], invulnTime);
            }
            else
            {
                return;
            }
        }
Пример #2
0
        /// <summary>
        /// Handles a use item request from the client
        /// </summary>
        static public void Handle_CS_PlayerUseItem(CS_PlayerUseItem pkt, Player player)
        {               //Allow the player's arena to handle it
            if (player._arena == null)
            {
                Log.write(TLog.Error, "Player {0} sent update packet with no arena.", player);
                return;
            }

            //Resolve the item in question
            ItemInfo item = player._server._assets.getItemByID(pkt.itemID);

            if (item == null)
            {
                Log.write(TLog.Warning, "Player {0} attempted to use non-existent item.", player);
                return;
            }

            if (player.IsSpectator)
            {
                Log.write(TLog.Warning, "Player {0} attempted to use item from spec '{1}'.", player, item.name);
                return;
            }

            //Check the player isn't lying about his coordinates
            if (!Helpers.isInRange(200, player._state.positionX, player._state.positionY, pkt.posX, pkt.posY))
            {
                Log.write(TLog.Warning, "Player {0} coordinate mismatch on item '{1}'.", player, item.name);
                return;
            }

            //Are we able to use it?
            if (!Logic_Assets.SkillCheck(player, item.skillLogic))
            {
                Log.write(TLog.Security, "Player {0} failed skill check to use item '{1}'.", player, item.name);
                return;
            }

            //The action taken depends on the type of item
            player._arena.handleEvent(delegate(Arena arena)
            {
                switch (item.itemType)
                {
                case ItemInfo.ItemType.Warp:
                    player._arena.handlePlayerWarp(player, item as ItemInfo.WarpItem, (ushort)pkt.targetVehicle, pkt.posX, pkt.posY);
                    break;

                case ItemInfo.ItemType.VehicleMaker:
                    player._arena.handlePlayerMakeVehicle(player, item as ItemInfo.VehicleMaker, pkt.posX, pkt.posY);
                    break;

                case ItemInfo.ItemType.ItemMaker:
                    player._arena.handlePlayerMakeItem(player, item as ItemInfo.ItemMaker, pkt.posX, pkt.posY);
                    break;

                case ItemInfo.ItemType.Repair:
                    player._arena.handlePlayerRepair(player, item as ItemInfo.RepairItem, (UInt16)pkt.targetVehicle, pkt.posX, pkt.posY);
                    break;

                case ItemInfo.ItemType.Control:
                    player._arena.handlePlayerControl(player, item as ItemInfo.ControlItem, (UInt16)pkt.targetVehicle, pkt.posX, pkt.posY);
                    break;
                }
            }
                                      );
        }