Esempio n. 1
0
        /// <summary>
        /// Drops or gives the ball upon death
        /// </summary>
        public void ballHandleDeath(Player victim, Player killer)
        {
            //Is this a ball type zone?
            if (_balls == null || _balls.Count() == 0)
            {
                return;
            }

            //Player?
            if (victim == null)
            {
                Log.write(TLog.Warning, "ballHandleDeath(): Called with null victim.");
                return;
            }

            //Do we even have a ball?
            if (victim._gotBallID == 999)
            {
                return;
            }

            Ball ball = _balls.SingleOrDefault(b => b._id == victim._gotBallID);

            victim._gotBallID = 999;

            if (ball == null)
            {
                return;
            }

            //Did the victim have the ball?
            if (ball._owner == victim)
            {
                ball._owner     = null;
                ball._lastOwner = victim;

                //Are we giving it to the killer?
                if (_server._zoneConfig.soccer.killerCatchBall && killer != null)
                {
                    //Pick the ball up
                    ball._state.positionX = killer._state.positionX;
                    ball._state.positionY = killer._state.positionY;
                    ball._state.positionZ = killer._state.positionZ;
                    ball._state.velocityX = 0;
                    ball._state.velocityY = 0;
                    ball._state.velocityZ = 0;
                    ball.deadBall         = false;

                    ball._owner       = killer;
                    killer._gotBallID = ball._id;

                    //Update spatial data
                    UpdateBall(ball);
                    Ball.Route_Ball(Players, ball); //Send it
                    return;
                }
            }
            //Spawn it otherwise
            Ball.Spawn_Ball(ball, victim._state.positionX, victim._state.positionY);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the ball action when a player dies carrying it
        /// </summary>
        public void ballResetPlayer(Player from, Player killer)
        {
            if (from == null)
            {
                return;
            }

            Ball ball = _balls.SingleOrDefault(b => b._owner != null && b._owner == from);

            if (ball == null)
            {
                return;
            }

            //Make sure they arent carrying one now
            from._gotBallID = 999;

            //Are we giving it to the killer?
            if (killer != null && _server._zoneConfig.soccer.killerCatchBall)
            {
                //Give it to the killer
                killer._gotBallID = ball._id;

                ball._lastOwner = from;
                ball._owner     = killer;

                ball.ballStatus = 0; //Picked up

                ball._state.positionX = killer._state.positionX;
                ball._state.positionY = killer._state.positionY;
                ball._state.positionZ = killer._state.positionZ;
                ball._state.velocityX = 0;
                ball._state.velocityY = 0;
                ball._state.velocityZ = 0;
                ball.deadBall         = false;

                int now        = Environment.TickCount;
                int updateTick = ((now >> 16) << 16) + (ball._state.lastUpdate & 0xFFFF);
                ball._state.lastUpdate       = updateTick;
                ball._state.lastUpdateServer = now;

                ball.tickCount = (uint)now;

                //Route
                updateBall(ball);
                return;
            }

            //Just spawn it in place instead
            Ball.Spawn_Ball(ball, from._state.positionX, from._state.positionY);
        }