コード例 #1
0
ファイル: ArenaState.cs プロジェクト: trjate/Infantry
        /// <summary>
        /// Called when a new player is entering our arena
        /// </summary>
        public void newPlayer(Player player)
        {       ///////////////////////////////////////////////
            // Prepare the player state
            ///////////////////////////////////////////////

            //We're entering the arena..
            player._arena = this;

            RecallPlayerStats(player);
            player.resetVars();

            player._ipAddress = player._client._ipe.Address;

            //TODO: Check rules for whether player enters in spec
            //_server._zoneConfig.arena.startInSpectator
            player._bSpectator = true;
            player._team       = _teams["spec"];

            //Find his natural vehicle id and prepare the class
            Player.SkillItem baseSkill = player._skills.Values.FirstOrDefault(skill => skill.skill.DefaultVehicleId != -1);
            int     baseVehicleID      = (baseSkill == null) ? _server._zoneConfig.publicProfile.defaultVItemId : baseSkill.skill.DefaultVehicleId;
            Vehicle baseVehicle        = new Vehicle(_server._assets.getVehicleByID(baseVehicleID), this);

            baseVehicle._bBaseVehicle = true;
            baseVehicle._id           = player._id;
            baseVehicle._state        = player._state;  //Player and basevehicle share same state

            player._baseVehicle = baseVehicle;

            //Run the initial events
            if (_server.IsStandalone)
            {
                player.firstTimeEvents();
            }

            if (player.firstTimePlayer)
            {
                Logic_Assets.RunEvent(player, _server._zoneConfig.EventInfo.firstTimeSkillSetup);
                Logic_Assets.RunEvent(player, _server._zoneConfig.EventInfo.firstTimeInvSetup);
                if (player._bIngame)
                {
                    player.firstTimePlayer = false;
                }
            }

            //Create our new spam filter list
            player._msgTimeStamps = new List <DateTime>();

            ///////////////////////////////////////////////
            // Send the player state
            ///////////////////////////////////////////////
            //Make sure he's receiving ingame packets
            player._client.sendReliable(new SC_SetIngame());

            //Add him to our list of players. We want to do this now so he doesn't lose
            //info about anything happening until then.
            if (!_players.Contains(player))
            {
                _players.Add(player);
            }

            //Check his processes quick
            SC_Environment env = new SC_Environment();

            env.bLimitLength = false;
            player._client.sendReliable(env);

            //Lets check his level and set watchMod
            if (player.PermissionLevel >= Data.PlayerPermission.ArenaMod)
            {
                player._watchMod = true;
            }

            //Check if we can use him as a reliable player [check if mod]
            if (player.PermissionLevel >= Data.PlayerPermission.ArenaMod)
            {
                player.setVar("reliable", player);
            }

            //Send a security check for their client asset checksum
            SC_SecurityCheck cs = new SC_SecurityCheck();

            cs.key     = 1015;       //Key we are using
            cs.unknown = 0;          // Unknown, send as 0
            player._client.send(cs); //Send it

            //Define the player's self object
            Helpers.Object_Players(player, player);

            //Make sure the player is aware of every player in the arena
            List <Player> audience = Players.ToList();

            //Check first for stealthed mods
            //Note: this is for any other players joining while there is a stealthed mod
            foreach (Player p in audience)
            {
                //Check their levels with the players level
                if (p != player)
                {
                    if (!p.IsStealth)
                    {
                        Helpers.Object_Players(player, p);
                    }
                    if (p.IsStealth && player.PermissionLevel >= p.PermissionLevel)
                    {
                        Helpers.Object_Players(player, p);
                    }
                }
            }

            //Load the arena's item state
            Helpers.Object_Items(player, _items.Values);

            //Load the arena's various lio objects
            Helpers.Object_Flags(player, _flags.Values);
            Helpers.Object_LIOs(player, _switches.Values);

            //Load the vehicles in the arena
            if (_vehicles.Count > 0)
            {
                Helpers.Object_Vehicles(player, _vehicles);
            }

            //Load the ball state if any
            if (_balls.Count > 0)
            {
                Helpers.Object_Ball(player, _balls);
            }

            //Suspend his stats if it's a private arena
            if (_bIsPublic)
            {
                player.restoreStats();
                player.suspendCalled = false;
            }
            else if (!player.suspendCalled)
            {
                player.suspendStats();
                player.suspendCalled = true;
            }

            //Is this a private arena and are we the first one?
            if (!player._arena._name.StartsWith("Public", StringComparison.OrdinalIgnoreCase) && player._arena.TotalPlayerCount == 1)
            {
                //Give player required privileges
                player._arena._owner.Add(player._alias);
                if (player.PermissionLevel < Data.PlayerPermission.ArenaMod)
                {
                    player._permissionTemp = Data.PlayerPermission.ArenaMod;
                    player._watchMod       = true;
                }
            }

            //Are we zone silenced or arena silenced?
            if (!this._server._playerSilenced.ContainsKey(player._ipAddress))
            {   //Since we are not in the zone list, check the arena list
                if (!this._silencedPlayers.ContainsKey(player._alias))
                {
                    player._bSilenced = false;
                }
                else
                {
                    player._bSilenced = true;
                }
            }

            //Initialize the player's state
            Helpers.Player_StateInit(player,
                                     delegate()
            {
                //Check for stealthing/cloaking mods first
                //Note: this is for the stealthed person entering
                if (!player.IsStealth)
                {
                    //Make sure everyone is aware of him
                    Helpers.Object_Players(audience, player);
                }
                else
                {     //Check their level vs people in the room
                    foreach (Player person in audience)
                    {
                        //Their level is the same or greater, allow them to see him/her
                        if (person != player && person.PermissionLevel >= player.PermissionLevel)
                        {
                            Helpers.Object_Players(person, player);
                        }
                    }
                }

                //Consider him loaded!
                player.spec();
                player.setIngame();

                //Load the tickers
                Helpers.Arena_Message(player, _tickers.Values);

                //Load all the banners
                Helpers.Social_UpdateBanner(player);                        //Players banner
                Helpers.Social_ArenaBanners(player._arena.Players, player); //Inform arena of his banner
                Helpers.Social_ArenaBanners(player, this);                  //Get all banners in arena
                //Set able to receive banners
                player._bAllowBanner = true;

                //Trigger our event for player entering arena
                callsync("Player.EnterArena", false, player);

                //Temporary player message, remove this later. This is just here to get old accounts to update their information
                player.sendMessage(-3, "[Notice] Welcome to Infantry! To get support simply use the discord link located on the top right of the infantry launcher. Enjoy your stay!");

                //Mod notice
                if (player.PermissionLevelLocal >= Data.PlayerPermission.ArenaMod && !player._arena.IsPrivate)
                {
                    player.sendMessage(-3, "$[Mod Notice] To see a list of commands, type *help. To specifically get info on a command type *help <command name>");
                }
            }
                                     );
        }
コード例 #2
0
ファイル: Arena.cs プロジェクト: mizzouse/FreeInfantry
        /// <summary>
        /// Called when a new player is entering our arena
        /// </summary>
        public void newPlayer(Player player)
        {               //Fake a player state
            player._cash            = 13337;
            player._experience      = 73331;
            player._experienceTotal = 80000;

            for (int i = 0; i < 8; ++i)
            {
                Player.SkillItem s = new Player.SkillItem();

                s.skill         = new Assets.SkillInfo();
                s.skill.skillID = i + 1;
                s.quantity      = 0;
                player._skills.Add(s);
            }

            int[] modWeps = new int[] { 1026, 1042, 1078, 1079, 1080, 1098, 1099, 1116, 1119, 1121, 1123, 1124, 427, 1125,
                                        1126, 1127, 1128, 1129, 1130, 1158, 1132, 1133, 1134, 1135, 1136, 1137, 1156, 1139,
                                        1140, 1141, 1142, 1143, 1144, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155,
                                        3049, 3006, 3046, 3047, 3007, 3048, 3012, 3015, 3039, 3040, 3041, 3042, 3043, 3044 };

            foreach (int wid in modWeps)
            {
                Player.InventoryItem i = new Player.InventoryItem();
                i.item     = _server._assets.getItemByID(wid);
                i.quantity = 1;
                player._inventory.Add(i);
            }

            //We're entering the arena..
            player._bIngame = false;

            //Make sure he's receiving ingame packets
            player._client.sendReliable(new SC_SetIngame());

            //Prepare his base vehicle (the vehicle his class naturally inherits
            Vehicle baseVehicle = new Vehicle(12);

            player._baseVehicle = baseVehicle;

            //HACK: Just three teams for now
            _teams.Values.SingleOrDefault(team => team._id == player._id % 3).addPlayer(player);

            //Define the player's self object
            Helpers.Object_Players(player, player);

            //Initialize the player's state
            Helpers.Player_StateInit(player);

            //Load the arena's item state
            Helpers.Object_Items(player, _items.Values);

            //Make sure the player is aware of every player in the arena
            Helpers.Object_Players(player, _players,
                                   delegate()
            {                           //And make sure everyone is aware of him
                Helpers.Object_Players(_players, player);

                //We can now add him to our list of players
                _players.Add(player);
                player._arena = this;

                //Consider him loaded!
                player.setIngame();
                player.warp(SC_PlayerWarp.WarpMode.Normal, 500, 4500);
            }
                                   );

            /*SC_ChangeTeam tchange = new SC_ChangeTeam();
             * tchange.playerID = player._id;
             * tchange.unk2 = 0x7D00;
             * tchange.teamname = "spec" + new Random().Next();
             * player._client.send(tchange);*/

            /*SC_Vehicles vehicles = new SC_Vehicles();
             * SC_Vehicles.VehicleInfo vi = new SC_Vehicles.VehicleInfo();
             * vi.vehicleID = 123;
             * vi.vehicleTypeID = 400;
             * vi.unk1 = -1;
             * vi.extraData = new byte[] { 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x56, 0x00, 0x00 };
             * vehicles.vehicles.Add(vi);
             * vi = new SC_Vehicles.VehicleInfo();
             * vi.vehicleID = 0x1B;
             * vi.vehicleTypeID = 1;
             * vi.unk1 = -1;
             * vi.extraData = new byte[] { 0xEA, 0x19, 0xAF, 0x25 };
             * vehicles.vehicles.Add(vi);
             *
             * client.send(vehicles);
             *
             * SC_Items items = new SC_Items();
             * Random rand = new Random();
             *
             * for (int i = 0; i < 35; ++i)
             * {
             *      SC_Items.ItemInfo ii = new SC_Items.ItemInfo();
             *      ii.pos_x = (ushort)rand.Next(20, 400);
             *      ii.pos_y = (ushort)rand.Next(20, 400);
             *      ii.itemID = (ushort)(i + 1);
             *      ii.itemTypeID = 2005;
             *      items.items.Add(ii);
             * }
             *
             * client.send(items);
             *
             * SC_ChangeTeam tchange = new SC_ChangeTeam();
             * tchange.playerID = 0x1B;
             * tchange.unk2 = 0x7D00;
             * tchange.teamname = "spec";
             * client.send(tchange);
             *
             * //Let's create a spectator vehicle
             * SC_Vehicles.VehicleInfo vi = new SC_Vehicles.VehicleInfo();
             * vi.vehicleID = 0x2B;
             * vi.vehicleTypeID = 1;
             * vi.unk1 = -1;
             * vi.extraData = new byte[] { 0, 0, 0, 0 };
             *
             * SC_Vehicles specVeh = new SC_Vehicles(vi);
             * client.send(specVeh);
             *
             * //Do some binds
             * SC_BindVehicle bind = new SC_BindVehicle();
             * bind.Vehicle1 = 0x1B;
             * bind.Vehicle2 = -1;
             * bind.extraData = new byte[] { 0x33, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
             * //client.send(bind);
             * bind = new SC_BindVehicle();
             * bind.Vehicle1 = 0x2B;
             * bind.Vehicle2 = 0x1B;
             * bind.extraData = new byte[] { 0x08, 0xDF, 0x15, 0xD9  };
             * client.send(bind);
             *
             * SC_EnterArena test = new SC_EnterArena();
             * client.send(test);*/
        }