コード例 #1
0
        private NpcSpawn ReadNpcSpawn(DbDataReader reader)
        {
            NpcSpawn npcSpawn = new NpcSpawn();

            npcSpawn.Id         = GetInt32(reader, "id");
            npcSpawn.ModelId    = GetInt32(reader, "model_id");
            npcSpawn.NpcId      = GetInt32(reader, "npc_id");
            npcSpawn.Level      = GetByte(reader, "level");
            npcSpawn.Name       = GetString(reader, "name");
            npcSpawn.Title      = GetString(reader, "title");
            npcSpawn.MapId      = GetInt32(reader, "map_id");
            npcSpawn.X          = GetFloat(reader, "x");
            npcSpawn.Y          = GetFloat(reader, "y");
            npcSpawn.Z          = GetFloat(reader, "z");
            npcSpawn.Active     = GetBoolean(reader, "active");
            npcSpawn.Heading    = GetByte(reader, "heading");
            npcSpawn.Size       = GetInt16(reader, "size");
            npcSpawn.Visibility = GetInt32(reader, "visibility");
            npcSpawn.Created    = GetDateTime(reader, "created");
            npcSpawn.Updated    = GetDateTime(reader, "updated");
            npcSpawn.Icon       = GetInt32(reader, "icon");
            npcSpawn.Status     = GetInt32(reader, "status");
            npcSpawn.Status_X   = GetInt32(reader, "status_x");
            npcSpawn.Status_Y   = GetInt32(reader, "status_y");
            npcSpawn.Status_Z   = GetInt32(reader, "status_z");
            return(npcSpawn);
        }
コード例 #2
0
        /*public List<DeadBody> SelectDeadBodiesByMapId(int mapId)
         * {
         *  List<DeadBody> deadBodies = new List<DeadBody>();
         *  ExecuteReader(SqlSelectDeadBodyByMapId,
         *      command => { AddParameter(command, "@map_id", mapId); },
         *      reader =>
         *      {
         *          while (reader.Read())
         *          {
         *              DeadBody deadBodies = ReadDeadBody(reader);
         *              deadBodies.Add(deadBodies);
         *          }
         *      });
         *  return deadBodies;
         * }*/

        public bool UpdateNpcSpawn(NpcSpawn npcSpawn)
        {
            int rowsAffected = ExecuteNonQuery(SqlUpdateNpcSpawn, command =>
            {
                AddParameter(command, "@id", npcSpawn.Id);
                AddParameter(command, "@npc_id", npcSpawn.NpcId);
                AddParameter(command, "@model_id", npcSpawn.ModelId);
                AddParameter(command, "@level", npcSpawn.Level);
                AddParameter(command, "@name", npcSpawn.Name);
                AddParameter(command, "@title", npcSpawn.Title);
                AddParameter(command, "@map_id", npcSpawn.MapId);
                AddParameter(command, "@x", npcSpawn.X);
                AddParameter(command, "@y", npcSpawn.Y);
                AddParameter(command, "@z", npcSpawn.Z);
                AddParameter(command, "@active", npcSpawn.Active);
                AddParameter(command, "@heading", npcSpawn.Heading);
                AddParameter(command, "@size", npcSpawn.Size);
                AddParameter(command, "@visibility", npcSpawn.Visibility);
                AddParameter(command, "@created", npcSpawn.Created);
                AddParameter(command, "@updated", npcSpawn.Updated);
                AddParameter(command, "@icon", npcSpawn.Icon);
                AddParameter(command, "@status", npcSpawn.Status);
                AddParameter(command, "@status_x", npcSpawn.Status_X);
                AddParameter(command, "@status_y", npcSpawn.Status_Y);
                AddParameter(command, "@status_z", npcSpawn.Status_Z);
            });

            return(rowsAffected > NoRowsAffected);
        }
コード例 #3
0
        public bool InsertNpcSpawn(NpcSpawn npcSpawn)
        {
            int rowsAffected = ExecuteNonQuery(SqlInsertNpcSpawn, command =>
            {
                AddParameter(command, "@npc_id", npcSpawn.NpcId);
                AddParameter(command, "@model_id", npcSpawn.ModelId);
                AddParameter(command, "@level", npcSpawn.Level);
                AddParameter(command, "@name", npcSpawn.Name);
                AddParameter(command, "@title", npcSpawn.Title);
                AddParameter(command, "@map_id", npcSpawn.MapId);
                AddParameter(command, "@x", npcSpawn.X);
                AddParameter(command, "@y", npcSpawn.Y);
                AddParameter(command, "@z", npcSpawn.Z);
                AddParameter(command, "@active", npcSpawn.Active);
                AddParameter(command, "@heading", npcSpawn.Heading);
                AddParameter(command, "@size", npcSpawn.Size);
                AddParameter(command, "@visibility", npcSpawn.Visibility);
                AddParameter(command, "@created", npcSpawn.Created);
                AddParameter(command, "@updated", npcSpawn.Updated);
                AddParameter(command, "@icon", npcSpawn.Icon);
                AddParameter(command, "@status", npcSpawn.Status);
                AddParameter(command, "@status_x", npcSpawn.Status_X);
                AddParameter(command, "@status_y", npcSpawn.Status_Y);
                AddParameter(command, "@status_z", npcSpawn.Status_Z);
            }, out long autoIncrement);

            if (rowsAffected <= NoRowsAffected || autoIncrement <= NoAutoIncrement)
            {
                return(false);
            }

            npcSpawn.Id = (int)autoIncrement;
            return(true);
        }
コード例 #4
0
        private void DonkeysItems(NecClient client, NpcSpawn npcSpawn)
        {
            if (client.Character.helperTextDonkey)
            {
                IBuffer res2 = BufferProvider.Provide();
                res2.WriteCString($"{npcSpawn.Name}");                                                                                               //need to find max size; Name
                res2.WriteCString($"{npcSpawn.Title}");                                                                                              //need to find max size; Title (inside chat box)
                res2.WriteCString(
                    "Wee! There's plenty of weapons and armor at the specialty shops. The weapon and armor shops are in Bustling Market. *Hiccup*"); //need to find max size; Text block
                Router.Send(client, (ushort)AreaPacketId.recv_event_message_no_object, res2, ServerType.Area);

                IBuffer res6 = BufferProvider.Provide();
                Router.Send(client, (ushort)AreaPacketId.recv_event_sync, res6, ServerType.Area);

                client.Character.helperTextDonkey = false;
            }
            else
            {
                IBuffer res4 = BufferProvider.Provide();
                //recv_shop_notify_open = 0x52FD, // Parent = 0x5243 // Range ID = 02
                res4.WriteInt16(
                    14); //Shop type, 1 = remove curse; 2 = purchase list; 3 = 1 and 2; 4 = sell; 5 = 1 and 4; 6 = 2 and 4; 7 = 1, 2, and 4; 8 = identify; 14 = purchase, sell, identify; 16 = repair;
                res4.WriteInt32(0);
                res4.WriteInt32(0);
                res4.WriteByte(0);
                Router.Send(client, (ushort)AreaPacketId.recv_shop_notify_open, res4, ServerType.Area);

                IBuffer res5 = BufferProvider.Provide();
                res5.WriteCString($"{npcSpawn.Name}'s Goods");
                Router.Send(client, (ushort)AreaPacketId.recv_shop_title_push, res5, ServerType.Area);
            }
        }
コード例 #5
0
        private void RecoverySpring(NecClient client, NpcSpawn npcSpawn)
        {
            IBuffer res = BufferProvider.Provide();

            res.WriteCString(npcSpawn.Title);     // Title at top of Window
            res.WriteUInt32(npcSpawn.InstanceId); //should pull name of NPC,  doesnt currently
            Router.Send(client, (ushort)AreaPacketId.recv_event_show_board_start, res, ServerType.Area);


            IBuffer res12 = BufferProvider.Provide();

            res12.WriteCString("The fountain is brimmed with water. Has enough for 5 more drinks."); // Length 0xC01
            Router.Send(client, (ushort)AreaPacketId.recv_event_system_message, res12,
                        ServerType.Area);                                                            // show system message on middle of the screen.


            IBuffer res3 = BufferProvider.Provide();

            res3.WriteCString("Drink");   //Length 0x601  // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res3,
                        ServerType.Area); // It's the first choice

            IBuffer res5 = BufferProvider.Provide();

            res5.WriteCString("Don't drink"); //Length 0x601 // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res5,
                        ServerType.Area);     // It's the second choice

            IBuffer res11 = BufferProvider.Provide();

            res11.WriteCString("Effect: Recover 50% of maximum HP and MP"); // Window Heading / Name
            res11.WriteUInt32(npcSpawn.InstanceId);
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_exec, res11,
                        ServerType.Area); // It's the windows that contain the multiple choice
        }
コード例 #6
0
        /*public List<DeadBody> SelectDeadBodiesByMapId(int mapId)
         * {
         *  List<DeadBody> deadBodies = new List<DeadBody>();
         *  ExecuteReader(SqlSelectDeadBodyByMapId,
         *      command => { AddParameter(command, "@map_id", mapId); },
         *      reader =>
         *      {
         *          while (reader.Read())
         *          {
         *              DeadBody deadBodies = ReadDeadBody(reader);
         *              deadBodies.Add(deadBodies);
         *          }
         *      });
         *  return deadBodies;
         * }*/

        public bool UpdateNpcSpawn(NpcSpawn npcSpawn)
        {
            int rowsAffected = ExecuteNonQuery(SQL_UPDATE_NPC_SPAWN, command =>
            {
                AddParameter(command, "@id", npcSpawn.id);
                AddParameter(command, "@npc_id", npcSpawn.npcId);
                AddParameter(command, "@model_id", npcSpawn.modelId);
                AddParameter(command, "@level", npcSpawn.level);
                AddParameter(command, "@name", npcSpawn.name);
                AddParameter(command, "@title", npcSpawn.title);
                AddParameter(command, "@map_id", npcSpawn.mapId);
                AddParameter(command, "@x", npcSpawn.x);
                AddParameter(command, "@y", npcSpawn.y);
                AddParameter(command, "@z", npcSpawn.z);
                AddParameter(command, "@active", npcSpawn.active);
                AddParameter(command, "@heading", npcSpawn.heading);
                AddParameter(command, "@size", npcSpawn.size);
                AddParameter(command, "@visibility", npcSpawn.visibility);
                AddParameter(command, "@created", npcSpawn.created);
                AddParameter(command, "@updated", npcSpawn.updated);
                AddParameter(command, "@icon", npcSpawn.icon);
                AddParameter(command, "@status", npcSpawn.status);
                AddParameter(command, "@status_x", npcSpawn.statusX);
                AddParameter(command, "@status_y", npcSpawn.statusY);
                AddParameter(command, "@status_z", npcSpawn.statusZ);
            });

            return(rowsAffected > NO_ROWS_AFFECTED);
        }
コード例 #7
0
        private NpcSpawn ReadNpcSpawn(DbDataReader reader)
        {
            NpcSpawn npcSpawn = new NpcSpawn();

            npcSpawn.id         = GetInt32(reader, "id");
            npcSpawn.modelId    = GetInt32(reader, "model_id");
            npcSpawn.npcId      = GetInt32(reader, "npc_id");
            npcSpawn.level      = GetByte(reader, "level");
            npcSpawn.name       = GetString(reader, "name");
            npcSpawn.title      = GetString(reader, "title");
            npcSpawn.mapId      = GetInt32(reader, "map_id");
            npcSpawn.x          = GetFloat(reader, "x");
            npcSpawn.y          = GetFloat(reader, "y");
            npcSpawn.z          = GetFloat(reader, "z");
            npcSpawn.active     = GetBoolean(reader, "active");
            npcSpawn.heading    = GetByte(reader, "heading");
            npcSpawn.size       = GetInt16(reader, "size");
            npcSpawn.visibility = GetInt32(reader, "visibility");
            npcSpawn.created    = GetDateTime(reader, "created");
            npcSpawn.updated    = GetDateTime(reader, "updated");
            npcSpawn.icon       = GetInt32(reader, "icon");
            npcSpawn.status     = GetInt32(reader, "status");
            npcSpawn.statusX    = GetInt32(reader, "status_x");
            npcSpawn.statusY    = GetInt32(reader, "status_y");
            npcSpawn.statusZ    = GetInt32(reader, "status_z");
            //Logger.Debug($"Reading Row {npcSpawn.Id}"); //for determining which row read throws SQL errors.
            return(npcSpawn);
        }
コード例 #8
0
        public bool InsertNpcSpawn(NpcSpawn npcSpawn)
        {
            int rowsAffected = ExecuteNonQuery(SQL_INSERT_NPC_SPAWN, command =>
            {
                AddParameter(command, "@npc_id", npcSpawn.npcId);
                AddParameter(command, "@model_id", npcSpawn.modelId);
                AddParameter(command, "@level", npcSpawn.level);
                AddParameter(command, "@name", npcSpawn.name);
                AddParameter(command, "@title", npcSpawn.title);
                AddParameter(command, "@map_id", npcSpawn.mapId);
                AddParameter(command, "@x", npcSpawn.x);
                AddParameter(command, "@y", npcSpawn.y);
                AddParameter(command, "@z", npcSpawn.z);
                AddParameter(command, "@active", npcSpawn.active);
                AddParameter(command, "@heading", npcSpawn.heading);
                AddParameter(command, "@size", npcSpawn.size);
                AddParameter(command, "@visibility", npcSpawn.visibility);
                AddParameter(command, "@created", npcSpawn.created);
                AddParameter(command, "@updated", npcSpawn.updated);
                AddParameter(command, "@icon", npcSpawn.icon);
                AddParameter(command, "@status", npcSpawn.status);
                AddParameter(command, "@status_x", npcSpawn.statusX);
                AddParameter(command, "@status_y", npcSpawn.statusY);
                AddParameter(command, "@status_z", npcSpawn.statusZ);
            }, out long autoIncrement);

            if (rowsAffected <= NO_ROWS_AFFECTED || autoIncrement <= NO_AUTO_INCREMENT)
            {
                return(false);
            }

            npcSpawn.id = (int)autoIncrement;
            return(true);
        }
コード例 #9
0
        private void SoulRankNpc(NecClient client, int objectId, NpcSpawn npcSpawn)
        {
            IBuffer res = BufferProvider.Provide();

            switch (client.character.eventSelectExecCode)
            {
            case 0:
                SendEventEnd(client);
                break;

            case 1:
                SendEventEnd(client);
                break;

            case 2:
                SendEventEnd(client);
                break;

            case 3:
                SendEventEnd(client);
                break;

            case 4:
                SendEventEnd(client);
                break;

            case 5:
                SendEventEnd(client);
                break;
            }
        }
コード例 #10
0
        private void CharaChangeChannel(NecClient client, NpcSpawn npcSpawn) //Usage TBD. calls up Send_Channel_Select
        {
            IBuffer res2 = BufferProvider.Provide();

            res2.WriteInt32(0);                            // error check
            res2.WriteUInt32(client.Character.InstanceId); // ??
            //sub_494c50
            res2.WriteInt32(client.Character.MapId);       //Stage ID from Stage.CSV
            res2.WriteInt32(client.Character
                            .MapId);                       //Map ID. Cross Refrences Dungeun_info.csv to get X/Y value for map icon, and dungeun description.
            res2.WriteInt32(partySize[2]);                 //max players
            res2.WriteInt16(levels[2]);
            //sub_4834C0
            res2.WriteByte(10); //loops to display
            //sub_494B90 - for loop
            for (int i = 0; i < 0x80; i++)
            {
                res2.WriteInt32(i);        //Channel ID for passing to Send_Channel_Select
                res2.WriteFixedString($"Channel {i}", 97);
                res2.WriteByte(1);         //bool 1 | 0
                res2.WriteInt16(0xF);      //Max players
                res2.WriteInt16((short)i); //Current players
                res2.WriteByte(3);
                res2.WriteByte(6);         //channel Emoticon - 6 for a Happy Face
                //
            }

            res2.WriteByte(10); //# of channels
            Router.Send(client, (ushort)MsgPacketId.recv_chara_select_channel_r, res2, ServerType.Msg);
        }
コード例 #11
0
        private void SpareEventParts(NecClient client, NpcSpawn npcSpawn)
        {
            //Move all this event stuff to an appropriate file/handler for re-use of common code
            ;

            /*
             * IBuffer res10 = BufferProvider.Provide();
             * res10.WriteCString("The fountain is brimmed with water. Has enough for 3 more drinks.");
             * res10.WriteCString("The fountain is brimmed with water. Has enough for 4 more drinks.");
             * res10.WriteCString("The fountain is brimmed with water. Has enough for 5 more drinks.");
             * Router.Send(client, (ushort)AreaPacketId.recv_event_block_message_no_object, res10, ServerType.Area);
             */
            /*
             * IBuffer res7 = BufferProvider.Provide();
             * res7.WriteInt32(instanceId);
             * res7.WriteCString("The fountain is brimmed with water. Has enough for 5 more drinks.");
             * Router.Send(client, (ushort)AreaPacketId.recv_event_block_message, res7, ServerType.Area);
             */

            /*
             * IBuffer res9 = BufferProvider.Provide();
             * res9.WriteCString($"NPC#:{instanceId}"); // Npc name manually entered
             * res9.WriteCString("QuestChat");//Chat Window lable
             * res9.WriteCString("You've got 5 seconds before this window closes. Think Quick!'");// it's the npc text, switch automatically to an other window when text finish
             * Router.Send(client, (ushort)AreaPacketId.recv_event_message_no_object, res9, ServerType.Area);
             */

            /*
             * IBuffer res8 = BufferProvider.Provide();
             * res8.WriteInt32(instanceId); // used to pull Name/Title information from the NPC/object being interacted with
             * res8.WriteCString("The fountain is brimmed with water. Has enough for 5 more drinks.");
             * Router.Send(client, (ushort)AreaPacketId.recv_event_message, res8, ServerType.Area);
             */

            /*
             * IBuffer res4 = BufferProvider.Provide();
             * res4.WriteCString("The fountain is brimmed with water. Has enough for 5 more drinks.");
             * res4.WriteInt32(0);
             * res4.WriteInt32(0);
             * res4.WriteInt32(0);
             * Router.Send(client, (ushort)AreaPacketId.recv_event_select_exec_winpos, res4, ServerType.Area); // It's the windows that contain the multiple choice
             */

            /*
             * IBuffer res6 = BufferProvider.Provide();
             * res6.WriteInt32(instanceId);
             * Router.Send(client, (ushort)AreaPacketId.recv_event_change_type, res6, ServerType.Area);//????
             */

            /*
             * IBuffer res2 = BufferProvider.Provide();
             * res2.WriteInt32(instanceId);
             * res2.WriteByte(1); // bool
             * Router.Send(client, (ushort)AreaPacketId.recv_event_select_ready, res2, ServerType.Area); //prevents the call to send_event_select_exec_r until you make a selection.
             */
        }
コード例 #12
0
        private void UnionWindow(NecClient client, NpcSpawn npcSpawn)
        {
            IBuffer res2 = BufferProvider.Provide();

            res2.WriteInt32(0);
            //Router.Send(client, (ushort)AreaPacketId.recv_union_request_establish_r, res2, ServerType.Area);
            IBuffer res = BufferProvider.Provide();

            //recv_union_open_window = 0x7D75,
            //no structure
            Router.Send(client, (ushort)AreaPacketId.recv_union_open_window, res, ServerType.Area);
        }
コード例 #13
0
        public static void Main(string[] args)
        {
            //Lets do the loading here to catch any exceptions.
            Console.WriteLine("For future updates visit http://www.CamSpark.com");
            MapData.load();  //this has to be packed once all mapdata is gotten.
            ObjectData.load();
            ItemData.load(); //this has to be first because npcDrops use itemData.. i think.
            NpcData.load();  //first load the npc data.
            NpcDrop.load();  //second load the npc drops. [order does matter here, as it binds to npcData].
            NpcSpawn.load(); //finally you can spawn the npcs.
            LaddersAndStairs.load();
            objectManager     = new WorldObjectManager();
            groundItemManager = new GroundItemManager();
            shopManager       = new ShopManager();
            minigames         = new MinigamesHandler();
            grandExchange     = new GrandExchange();
            clanManager       = new ClanManager();
            packetHandlers    = new PacketHandlers();
            loginHandler      = new LoginHandler();

            registerEvent(new RunEnergyEvent());
            registerEvent(new LevelChangeEvent());
            registerEvent(new SpecialRestoreEvent());
            registerEvent(new SkullCycleEvent());
            registerEvent(new AreaVariables());
            registerEvent(new AggressiveNpcEvent());
            registerEvent(new LowerPotionCyclesEvent());
            objectManager.getFarmingPatches().processPatches();
            isRunning = true;
            new Thread(new ThreadStart(Server.gameThread)).Start();
            new Thread(new ThreadStart(Server.eventProcessingThread)).Start();

            Console.Title = "Runescape 2 530 C# Server";

            // Startup the Server Listener
            try
            {
                IPEndPoint ipe = new IPEndPoint(0, Constants.SERVER_PORT);
                serverListenerSocket = new System.Net.Sockets.Socket(ipe.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                serverListenerSocket.Bind(ipe);
                serverListenerSocket.Listen(25); //backlog
                serverListenerSocket.BeginAccept(new AsyncCallback(acceptCallback), serverListenerSocket);
                Console.WriteLine("Runescape 2 530 C# server started on port " + Constants.SERVER_PORT);
            }
            catch (SocketException ioe)
            {
                misc.WriteError("Error: Unable to startup listener on " + Constants.SERVER_PORT + " - port already in use?");
                misc.WriteError(ioe.Message.ToString());
                isRunning = false;
            }
        }
コード例 #14
0
        public List <NpcSpawn> SelectNpcSpawns()
        {
            List <NpcSpawn> npcSpawns = new List <NpcSpawn>();

            ExecuteReader(SQL_SELECT_NPC_SPAWNS, reader =>
            {
                while (reader.Read())
                {
                    NpcSpawn npcSpawn = ReadNpcSpawn(reader);
                    npcSpawns.Add(npcSpawn);
                }
            });
            return(npcSpawns);
        }
コード例 #15
0
        public List <NpcSpawn> SelectNpcSpawnsByMapId(int mapId)
        {
            List <NpcSpawn> npcSpawns = new List <NpcSpawn>();

            ExecuteReader(SQL_SELECT_NPC_SPAWNS_BY_MAP_ID,
                          command => { AddParameter(command, "@map_id", mapId); },
                          reader =>
            {
                while (reader.Read())
                {
                    NpcSpawn npcSpawn = ReadNpcSpawn(reader);
                    npcSpawns.Add(npcSpawn);
                }
            });
            return(npcSpawns);
        }
コード例 #16
0
        private void Abdul(NecClient client, NpcSpawn npcSpawn)

        {
            if (client.Character.helperTextAbdul)

            {
                IBuffer res2 = BufferProvider.Provide();
                res2.WriteCString($"{npcSpawn.Name}");       //need to find max size; Name
                res2.WriteCString($"{npcSpawn.Title}");      //need to find max size; Title (inside chat box)
                res2.WriteCString("I used to drive a cab."); //need to find max size; Text block
                Router.Send(client, (ushort)AreaPacketId.recv_event_message_no_object, res2, ServerType.Area);

                IBuffer res6 = BufferProvider.Provide();
                Router.Send(client, (ushort)AreaPacketId.recv_event_sync, res6, ServerType.Area);

                client.Character.helperTextAbdul = false;
            }
            else
            {
                IBuffer res = BufferProvider.Provide();
                res.WriteCString(npcSpawn.Title);     // Title at top of Window
                res.WriteUInt32(npcSpawn.InstanceId); //should pull name of NPC,  doesnt currently
                Router.Send(client, (ushort)AreaPacketId.recv_event_show_board_start, res, ServerType.Area);

                IBuffer res3 = BufferProvider.Provide();
                res3.WriteCString("Accept Mission"); //Length 0x601  // name of the choice
                Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res3,
                            ServerType.Area);        // It's the first choice

                IBuffer res4 = BufferProvider.Provide();
                res4.WriteCString("Report Mission"); //Length 0x601 // name of the choice
                Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res4,
                            ServerType.Area);        // It's the second choice

                IBuffer res5 = BufferProvider.Provide();
                res5.WriteCString("Back");    //Length 0x601 // name of the choice
                Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res5,
                            ServerType.Area); // It's the second choice

                IBuffer res11 = BufferProvider.Provide();
                res11.WriteCString("Pick a Button..  What are you waiting for"); // Window Heading / Name
                res11.WriteUInt32(npcSpawn.InstanceId);
                Router.Send(client, (ushort)AreaPacketId.recv_event_select_exec, res11,
                            ServerType.Area); // It's the windows that contain the multiple choice
            }
        }
コード例 #17
0
        private void UpdateNpc(NecClient client, NpcSpawn npcSpawn)
        {
            if (client.character.eventSelectExecCode == 0)
            {
                npcSpawn.heading = (byte)(client.character.heading + 90);
                npcSpawn.heading = (byte)(npcSpawn.heading % 180);
                if (npcSpawn.heading < 0)
                {
                    npcSpawn.heading += 180;
                }

                npcSpawn.updated = DateTime.Now;


                if (!server.database.UpdateNpcSpawn(npcSpawn))
                {
                    IBuffer res12 = BufferProvider.Provide();
                    res12.WriteCString("Could not update the database"); // Length 0xC01
                    router.Send(client, (ushort)AreaPacketId.recv_event_system_message, res12,
                                ServerType.Area);                        // show system message on middle of the screen.
                    return;
                }

                IBuffer res13 = BufferProvider.Provide();
                res13.WriteCString("NPC Updated"); // Length 0xC01
                router.Send(client, (ushort)AreaPacketId.recv_event_system_message, res13,
                            ServerType.Area);      // show system message on middle of the screen.

                RecvEventEnd(client);              //End The Event
            }
            else if (client.character.eventSelectExecCode == 1)
            {
                NpcModelUpdate npcModelUpdate = new NpcModelUpdate();
                server.instances.AssignInstance(npcModelUpdate);
                npcModelUpdate.npcSpawn = npcSpawn;

                client.character.currentEvent = npcModelUpdate;

                IBuffer             res14      = BufferProvider.Provide();
                RecvEventRequestInt getModelId = new RecvEventRequestInt("Select Model ID from Model_common.csv", 11000,
                                                                         1911105, npcSpawn.modelId);
                router.Send(getModelId, client);
            }
        }
コード例 #18
0
        public void AttackNpc(Vector2 target, NpcSpawn npcSpawn)
        {
            SendAttackPacket(_player, target);
            ServerNpc npc = (ServerNpc)npcSpawn;

            if (npc == null)
            {
                return;
            }

            if (_player.InCombat && _player.NpcInCombatWith != npc)
            {
                _player.SendChatMessage("You're already fighting something else!");
                return;
            }

            if (npc.PlayerInCombatWith != null && npc.PlayerInCombatWith != _player)
            {
                _player.SendChatMessage($"NPC[{npc.Name}] is already in combat.");
                return;
            }

            if (npc != null && npc.IsAttackable(_player))
            {
                byte damage = (byte)CalculateHitDamage(_player, npc);
                AddExperience(damage);
                npc.TakeDamage(damage, _player);
                if (!npc.Alive)
                {
                    return;
                }

                NpcTakeDamagePacket damagePacket = new NpcTakeDamagePacket
                {
                    PlayerDoingDamage = _player.Id,
                    NpcSpawnId        = npc.SpawnId,
                    Damage            = damage,
                    CurrentHealth     = npc.CurrentHealth
                };

                ServerPacketHandler.Instance.SendSerializablePacketToRenderedPlayers(PacketType.NpcTakeDamage, damagePacket, DeliveryMethod.ReliableUnordered, npc.CurrentServerPosition);
            }
        }
コード例 #19
0
        private void LostBBS(NecClient client, NpcSpawn npcSpawn)
        {
            IBuffer res = BufferProvider.Provide();

            //recv_message_board_notify_open = 0x170F,

            res.WriteInt32(2); //String lookup inside str_table.csv around line 3366

            res.WriteInt16(2);
            res.WriteInt16(4); // Lost souls yesterday.
            res.WriteInt16(6);
            res.WriteInt16(8);

            res.WriteInt16(10);
            res.WriteInt16(12); // Lost souls last month.
            res.WriteInt16(14);
            res.WriteInt16(16);

            Router.Send(client.Map, (ushort)AreaPacketId.recv_message_board_notify_open, res, ServerType.Area);
        }
コード例 #20
0
        // I added these to Npc database for now, should it be handled differently?????
        private void SendGetWarpTarget(NecClient client, NpcSpawn npcSpawn)
        {
            client.Character.eventSelectExecCode = -1;
            Logger.Debug(
                $"npcSpawn.Id: {npcSpawn.Id}  |   npcSpawn.NpcId: {npcSpawn.NpcId} client.Character.eventSelectExecCode: {client.Character.eventSelectExecCode}");
            if (client.Character.eventSelectExecCode == -1)
            {
                IBuffer res3 = BufferProvider.Provide();
                if (client.Character.MapId == 2002104)  // Roswald Fort #1 to #2
                {
                    res3.WriteCString("Isolated Hall"); //Length 0x601
                }
                else if (client.Character.MapId == 2002105 || client.Character.MapId == 2002106
                         )                            // Roswald Fort #2/#3 to #1
                {
                    res3.WriteCString("Rusted Gate"); //Length 0x601
                }

                Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res3,
                            ServerType.Area); // It's the first choice

                IBuffer res70 = BufferProvider.Provide();
                if (client.Character.MapId == 2002104 || client.Character.MapId == 2002105) // Roswald Fort #1/#2 to #3
                {
                    res70.WriteCString("Severed Corridor");                                 //Length 0x601
                }
                else if (client.Character.MapId == 2002106)                                 // Roswald Fort #3 to #2
                {
                    res70.WriteCString("Isolated Hall");                                    //Length 0x601
                }

                Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res70,
                            ServerType.Area); // It's the second choice

                IBuffer res1 = BufferProvider.Provide();
                res1.WriteCString("Select area to travel to"); // It's the title dude
                res1.WriteUInt32(npcSpawn.InstanceId);         // This is the Event Type.  0xFFFD sends a 58 byte packet
                Router.Send(client, (ushort)AreaPacketId.recv_event_select_exec, res1,
                            ServerType.Area);                  // Actual map change is handled by send_event_select_exec_r, need to figure out how to handle this better
            }
        }
コード例 #21
0
        private void UpdateNPC(NecClient client, NpcSpawn npcSpawn)
        {
            IBuffer res3 = BufferProvider.Provide();

            res3.WriteCString("Set the NPC Heading in Database"); //Length 0x601  // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res3,
                        ServerType.Area);                         // It's the first choice

            IBuffer res5 = BufferProvider.Provide();

            res5.WriteCString("Update the Model ID of NPC in Database"); //Length 0x601 // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res5,
                        ServerType.Area);                                // It's the second choice

            IBuffer res11 = BufferProvider.Provide();

            res11.WriteCString("Which Admin function would you like to do?"); // Window Heading / Name
            res11.WriteUInt32(npcSpawn.InstanceId);
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_exec, res11,
                        ServerType.Area); // It's the windows that contain the multiple choice
        }
コード例 #22
0
        private void CrimInn(NecClient client, NpcSpawn npcSpawn)
        {
            IBuffer res2 = BufferProvider.Provide();

            res2.WriteCString("While Beginner (Usable until SR 2) 100 G");                           //Length 0x601  // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res2, ServerType.Area); // 0

            IBuffer res3 = BufferProvider.Provide();

            res3.WriteCString("Pig stable : Free!");                                                 //Length 0x601  // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res3, ServerType.Area); // 1

            IBuffer res4 = BufferProvider.Provide();

            res4.WriteCString("Storage room : 60 G");                                                //Length 0x601 // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res4, ServerType.Area); // 2

            IBuffer res5 = BufferProvider.Provide();

            res5.WriteCString("Sleeper : 300 G");                                                    //Length 0x601 // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res5, ServerType.Area); // 3

            IBuffer res6 = BufferProvider.Provide();

            res6.WriteCString("Slum Suite : 10,000 G");                                              //Length 0x601 // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res6, ServerType.Area); // 4

            IBuffer res8 = BufferProvider.Provide();

            res8.WriteCString("Back");                                                               //Length 0x601 // name of the choice
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_push, res8, ServerType.Area); // 5

            IBuffer res9 = BufferProvider.Provide();

            res9.WriteCString("Welcome! Please choose a room to stay in!"); // Window Heading / Name
            res9.WriteUInt32(npcSpawn.InstanceId);
            Router.Send(client, (ushort)AreaPacketId.recv_event_select_exec, res9,
                        ServerType.Area); // It's the windows that contain the multiple choice
        }
コード例 #23
0
        private void Blacksmith(NecClient client, NpcSpawn npcSpawn)
        {
            if (client.Character.helperTextBlacksmith)
            {
                IBuffer res2 = BufferProvider.Provide();
                res2.WriteCString($"{npcSpawn.Name}");                                                                                                  //need to find max size; Name
                res2.WriteCString($"{npcSpawn.Title}");                                                                                                 //need to find max size; Title (inside chat box)
                res2.WriteCString(
                    "By forging, you can use the same equipment for a long time. The equipment will get more powerful the more you forge. Of course,"); //need to find max size; Text block
                Router.Send(client, (ushort)AreaPacketId.recv_event_message_no_object, res2, ServerType.Area);

                IBuffer res3 = BufferProvider.Provide();
                res3.WriteCString($"{npcSpawn.Name}");             //need to find max size; Name
                res3.WriteCString($"{npcSpawn.Title}");            //need to find max size; Title (inside chat box)
                res3.WriteCString("sometimes the process fails."); //need to find max size; Text block
                Router.Send(client, (ushort)AreaPacketId.recv_event_message_no_object, res3, ServerType.Area);

                IBuffer res6 = BufferProvider.Provide();
                Router.Send(client, (ushort)AreaPacketId.recv_event_sync, res6, ServerType.Area);

                client.Character.helperTextBlacksmith = false;
            }
            else
            {
                IBuffer res4 = BufferProvider.Provide();
                //recv_shop_notify_open = 0x52FD, // Parent = 0x5243 // Range ID = 02
                res4.WriteInt16(
                    0b11111010); //Shop type, 1 = remove curse; 2 = purchase list; 3 = 1 and 2; 4 = sell; 5 = 1 and 4; 6 = 2 and 4; 7 = 1, 2, and 4; 8 = identify; 16 = repair;
                res4.WriteInt32(10800405);
                res4.WriteInt32(10800405);
                res4.WriteByte(0);
                Router.Send(client, (ushort)AreaPacketId.recv_shop_notify_open, res4, ServerType.Area);

                IBuffer res5 = BufferProvider.Provide();
                res5.WriteCString($"{npcSpawn.Name} the {npcSpawn.Title}");
                Router.Send(client, (ushort)AreaPacketId.recv_shop_title_push, res5, ServerType.Area);
            }
        }
コード例 #24
0
        private void CloakRoomShopClerk(NecClient client, NpcSpawn npcSpawn)
        {
            if (client.Character.helperTextCloakRoom)
            {
                IBuffer res2 = BufferProvider.Provide();
                res2.WriteCString($"{npcSpawn.Name}");                      //need to find max size; Name
                res2.WriteCString($"{npcSpawn.Title}");                     //need to find max size; Title (inside chat box)
                res2.WriteCString(
                    "Welcome! We take care of your belongings and money."); //need to find max size; Text block
                Router.Send(client, (ushort)AreaPacketId.recv_event_message_no_object, res2, ServerType.Area);

                IBuffer res6 = BufferProvider.Provide();
                Router.Send(client, (ushort)AreaPacketId.recv_event_sync, res6, ServerType.Area);

                client.Character.helperTextCloakRoom = false;
            }
            else
            {
                IBuffer res4 = BufferProvider.Provide();
                //recv_event_soul_storage_open = 0x3DD0,
                res4.WriteInt64(client.Soul.WarehouseGold); // Gold in the storage
                Router.Send(client, (ushort)AreaPacketId.recv_event_soul_storage_open, res4, ServerType.Area);
            }
        }