Beispiel #1
0
        /// <summary>
        /// Provides an easy means of routing bot update packets to players
        /// </summary>
        static public void Update_RouteBot(Bot update)
        {               //Prepare the appropriate packets
            SC_PlayerTeamUpdate tu = new SC_PlayerTeamUpdate();

            tu.tickUpdate      = Environment.TickCount;
            tu.player          = null;
            tu.vehicle         = update;
            tu.itemID          = (short)update._itemUseID;
            tu.activeUtilities = update._activeEquip;
            tu.bBot            = true;

            SC_PlayerUpdate up = new SC_PlayerUpdate();

            up.tickUpdate      = Environment.TickCount;
            up.player          = null;
            up.vehicle         = update;
            up.itemID          = (short)update._itemUseID;
            up.activeUtilities = update._activeEquip;
            up.bBot            = true;

            //Get the routing audience
            int weaponRouteRange = 0;

            if (update._itemUseID != 0)
            {
                ItemInfo item = AssetManager.Manager.getItemByID(update._itemUseID);
                if (item != null)
                {
                    item.getRouteRange(out weaponRouteRange);
                }
                else
                {
                    Log.write(TLog.Warning, "RouteBot(): item is null");
                }
            }

            List <Player> audience = getRouteList(update._arena, update._state, (update._itemUseID != 0), weaponRouteRange, null,
                                                  update._state.positionX, update._state.positionY);

            //Send our updates..
            foreach (Player player in audience)
            {
                if (player.IsSpectator || player._team == update._team)
                {
                    player._client.send(tu);
                }
                else
                {
                    player._client.send(up);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Provides an easy means of routing computer vehicle update messages
        /// </summary>
        static public void Update_RouteComputer(Computer update)
        {               //Prepare the appropriate packets
            SC_PlayerTeamUpdate tu = new SC_PlayerTeamUpdate();

            tu.tickUpdate = Environment.TickCount;
            tu.player     = null;
            tu.vehicle    = update;
            tu.itemID     = (short)(update._shouldFire ? update._primaryGun.id : -1);

            //We only route active utilities if we're not broken
            if (update._state.health > update._type.HitpointsRequiredToOperate)
            {
                tu.activeUtilities = update._activeEquip;
            }

            //TODO: Should we use SC_PlayerUpdate for computers too?

            //Get the audience
            int weaponRouteRange = 0;

            if (update._primaryGun != null)
            {
                update._primaryGun.getRouteRange(out weaponRouteRange);
            }

            List <Player> audience = getRouteList(update._arena, update._state, update._shouldFire, weaponRouteRange, null,
                                                  update._state.positionX, update._state.positionY);

            //Send our updates..
            foreach (Player player in audience)
            {
                player._client.send(tu);
            }

            // Disable fire
            update._shouldFire = false;
            update._sendUpdate = false;
        }
Beispiel #3
0
        /// <summary>
        /// Provides an easy means of routing movement update messages between players
        /// </summary>
        static public void Update_RoutePlayer(Player update, CS_PlayerUpdate pkt, int updateTick, int oldPosX, int oldPosY)
        {               //Prepare the appropriate packets
            SC_PlayerTeamUpdate tu = new SC_PlayerTeamUpdate();

            tu.tickUpdate = updateTick;
            tu.player     = update;
            tu.vehicle    = update.ActiveVehicle;
            tu.itemID     = pkt.itemID;

            tu.activeEquip = pkt.activeEquip;

            SC_PlayerUpdate up = new SC_PlayerUpdate();

            up.tickUpdate = updateTick;
            up.player     = update;
            up.vehicle    = update.ActiveVehicle;
            up.itemID     = pkt.itemID;

            up.activeEquip = pkt.activeEquip;

            //Get the routing audience

            bool itemUpdate        = false;
            bool itemRouteFriendly = false;
            int  weaponRouteRange  = 0;

            if (pkt.itemID != 0)
            {
                itemUpdate = true;
                ItemInfo item = _server._assets.getItemByID(pkt.itemID);
                if (item != null)
                {
                    itemRouteFriendly = item.routeFriendly;
                    item.getRouteRange(out weaponRouteRange);
                }
                else
                {
                    Log.write(TLog.Warning, "Update_RoutePlayer(): item is null");
                }
            }

            List <Player> audience = getRouteList(update._arena, update._state, itemUpdate, weaponRouteRange, update._spectators, oldPosX, oldPosY);

            //Send our updates..
            foreach (Player player in audience)
            {                   //Don't send duplicates
                if (player == update)
                {
                    continue;
                }

                //Are we updating an item?
                if (itemUpdate)
                {
                    //Route friendly?
                    if (itemRouteFriendly)
                    {
                        //Route only to teammates.
                        if (player._team == update._team)
                        {
                            player._client.send(tu);
                        }
                        continue;
                    }
                }

                if (player.IsSpectator || player._team == update._team)
                {
                    player._client.send(tu);
                }
                else
                {
                    player._client.send(up);
                }
            }
        }