コード例 #1
0
ファイル: Npc.cs プロジェクト: ABooDY88HD/Tartarus-old
        public static void Init()
        {
            ConsoleUtils.Write(ConsoleMsgType.Status, "Loading NPC Database...\n");

            Database        db     = new Database(Server.GameDbConString);
            MySqlDataReader reader =
                db.ReaderQuery(
                    "SELECT `id`, `x`, `y`, `face`, `script` " +
                    "FROM `npc_db`", null, null
                    );

            while (reader.Read())
            {
                Npc npc = GObjectManager.GetNewNpc();

                npc.Id            = (int)reader["id"];
                npc.Position      = new Point((int)reader["x"], (int)reader["y"]);
                npc.Face          = (sbyte)reader["face"];
                npc.ContactScript = (string)reader["script"];

                RegionMngr.AddNpcToRegion(npc);
            }

            ConsoleUtils.Write(ConsoleMsgType.Status, "NPC Database Loaded.\n");
        }
コード例 #2
0
        // TODO : Target must not be optional
        public void Send(GameObject srcObject, PacketStream data, SendTarget target = SendTarget.Self)
        {
            byte[] byteData = data.GetPacket().ToArray();
            if (target == SendTarget.Self && srcObject.SubType != GameObjectSubType.Player)
            {
                ConsoleUtils.Write(ConsoleMsgType.Error, "Non-Player object trying to send packet to Self");
                return;
            }
            else if (target == SendTarget.Self)
            {
                SendPacket((Player)srcObject, byteData);
            }

            uint rx = RegionMngr.GetRegionX(srcObject.Position.X);
            uint ry = RegionMngr.GetRegionY(srcObject.Position.Y);

            foreach (Player p in GObjectManager.Players.Values)
            {
                if (target == SendTarget.Area)
                {
                    // If it's out of range
                    if (p.RegionX < rx - 3 || p.RegionX > rx + 3 ||
                        p.RegionY < ry - 3 || p.RegionY > ry + 3
                        )
                    {
                        continue;
                    }
                }

                SendPacket(p, byteData);
            }
        }
コード例 #3
0
        /// [0x0007] 7 - (CG) Tells where the player currently is while moving
        /// <player handle>.L <current x>.L <current y>.L <stop>.B
        internal static void parse_PCMoveUpdate(Player player, ref PacketStream stream, short[] pos)
        {
            uint  handle = stream.ReadUInt32(pos[0]);
            float curX   = stream.ReadFloat(pos[1]);
            float curY   = stream.ReadFloat(pos[2]);
            //int unknown = stream.ReadInt32(pos[3]);
            bool stop = stream.ReadBool(pos[4]);

            RegionMngr.UpdatePCPos(player, curX, curY, stop);
        }
コード例 #4
0
        public static void SpawnMonster(int mobId, Point position)
        {
            Monster mob = GObjectManager.GetNewMob();

            mob.Id       = mobId;
            mob.MaxHp    = MonsterDb.DB[mobId].Hp;
            mob.MaxMp    = MonsterDb.DB[mobId].Mp;
            mob.Hp       = mob.MaxHp;
            mob.Mp       = mob.MaxMp;
            mob.Position = position;

            RegionMngr.AddMobToRegion(mob);
        }
コード例 #5
0
        /// [0x0005] 5 - (CG) Requests to move from a position to another
        /// <player handle>.L <from x>.L <from y>.L <dest x>.L <dest y>.L
        internal static void parse_PCMoveRequest(Player player, ref PacketStream stream, short[] pos)
        {
            uint  handle    = stream.ReadUInt32(pos[0]);
            float fromX     = stream.ReadFloat(pos[1]);
            float fromY     = stream.ReadFloat(pos[2]);
            uint  time      = stream.ReadUInt32(pos[3]);
            byte  speedSync = stream.ReadByte(pos[4]);
            short moveCount = stream.ReadInt16(pos[5]);

            Point[] movePos = new Point[moveCount];
            for (int i = 0; i < moveCount; i++)
            {
                movePos[i]   = new Point();
                movePos[i].X = stream.ReadFloat(pos[6] + 8 * i);
                movePos[i].Y = stream.ReadFloat(pos[7] + 8 * i);
            }

            RegionMngr.PcWalkCheck(player, fromX, fromY, movePos);
        }
コード例 #6
0
        /// <summary>
        /// Loads a character data
        /// </summary>
        /// <param name="charName">the name of the character</param>
        /// <returns>true on success, false otherwise</returns>
        internal bool LoadCharacter(string charName)
        {
            Database db = new Database(Server.UserDbConString);
            // TODO : Query CleanUP

            MySqlDataReader reader =
                db.ReaderQuery(
                    "SELECT `char_id`,`slot`,`sex`,`race`," +
                    "`hair_id`,`face_id`,`body_id`,`hands_id`,`feet_id`," +
                    "`face_detail_id`,`hair_color`,`skin_color`,`x`,`y`,`layer`," +
                    "`save_x`,`save_y`,`level`,`exp`,`job`,`job_level`, `client_info`," +
                    "`jp`" +
                    " FROM `char`" +
                    " WHERE `account_id` = @accId AND `name` = @name AND `delete_date`= 0",
                    new string[] { "accId", "name" },
                    new object[] { this.AccountId, charName }
                    );

            if (!reader.Read())
            {
                // Character not in account
                ConsoleUtils.Write(ConsoleMsgType.Warning, "User trying to get a character that is not in his account.\n");
                return(false);
            }

            this.MaxStamina = Globals.MaxStamina;
            this.MaxChaos   = 0;
            this.MaxHavoc   = 0;

            this.Gold  = 0;
            this.Chaos = 0;
            this.TP    = 0;

            this.HairColor = (int)reader["hair_color"];
            this.HairId    = (int)reader["hair_id"];
            this.FaceId    = (int)reader["face_id"];
            this.BodyId    = (int)reader["body_id"];
            this.HandsId   = (int)reader["hands_id"];
            this.FeetId    = (int)reader["feet_id"];

            this.Name = charName;
            this.Race = (Races)(int)reader["race"];
            this.Sex  = (int)reader["sex"];
            // TODO : FIX
            this.SkinColor = (uint)(int)reader["skin_color"];
            this.CharId    = (int)reader["char_id"];

            this.Position = new Point((int)reader["x"], (int)reader["y"]);
            this.Layer    = (byte)(int)reader["layer"];

            this.ClientInfo = (string)reader["client_info"];

            this.LoadQuest();

            this.RegionX = RegionMngr.GetRegionX(this.Position.X);
            this.RegionY = RegionMngr.GetRegionY(this.Position.Y);

            //==== Character level/job/skills/buffs loading
            this.Level    = (int)reader["level"];
            this.Job      = (short)reader["job"];
            this.JobLevel = (int)reader["job_level"];
            this.JP       = (long)reader["jp"];

            this.LoadInventory();
            this.LoadSummons();

            this.LoadStats();
            this.LoadSkills();

            // TODO  Most of these packets probably can be placed in their own methods
            ClientPacketHandler.send_UpdateStats(this, false);
            ClientPacketHandler.send_UpdateStats(this, true);

            ClientPacketHandler.send_Property(this, "max_havoc", this.MaxHavoc);
            ClientPacketHandler.send_Property(this, "max_chaos", this.MaxChaos);
            ClientPacketHandler.send_Property(this, "max_stamina", this.MaxStamina);

            ClientPacketHandler.send_LoginResult(this);

            ClientPacketHandler.send_InventoryList(this);
            ClientPacketHandler.send_EquipSummon(this);
            ClientPacketHandler.send_CharacterView(this);
            ClientPacketHandler.send_UpdateGoldChaos(this);

            ClientPacketHandler.send_Property(this, "tp", this.TP);
            ClientPacketHandler.send_Property(this, "chaos", this.Chaos);

            ClientPacketHandler.send_UpdateLevel(this);
            ClientPacketHandler.send_UpdateExp(this);

            ClientPacketHandler.send_Property(this, "job", this.Job);

            ClientPacketHandler.send_Property(this, "job_level", this.JobLevel);
            ClientPacketHandler.send_Property(this, "job_0", 0);
            ClientPacketHandler.send_Property(this, "jlv_0", 0);
            ClientPacketHandler.send_Property(this, "job_1", 0);
            ClientPacketHandler.send_Property(this, "jlv_1", 0);
            ClientPacketHandler.send_Property(this, "job_2", 0);
            ClientPacketHandler.send_Property(this, "jlv_2", 0);

            if (this.SkillList.Count > 0)
            {
                ClientPacketHandler.send_SkillList(this, this.SkillList.Values.ToArray());
            }

            ClientPacketHandler.send_Packet404(this);
            ClientPacketHandler.send_Packet1005(this);

            ClientPacketHandler.send_BeltSlotInfo(this);
            ClientPacketHandler.send_GameTime(this);

            ClientPacketHandler.send_Property(this, "huntaholic_point", 0);
            ClientPacketHandler.send_Property(this, "huntaholic_ent", 12);
            ClientPacketHandler.send_Property(this, "ap", 0);

            ClientPacketHandler.send_Packet4700(this);

            ClientPacketHandler.send_Property(this, "alias", 0, true, "");
            ClientPacketHandler.send_Property(this, "ethereal_stone", 0);
            ClientPacketHandler.send_Property(this, "dk_count", 0);
            ClientPacketHandler.send_Property(this, "pk_count", 0);
            ClientPacketHandler.send_Property(this, "immoral", 0);
            ClientPacketHandler.send_Property(this, "stamina", 0);
            ClientPacketHandler.send_Property(this, "max_stamina", this.MaxStamina);
            ClientPacketHandler.send_Property(this, "channel", 1);

            ClientPacketHandler.send_EntityState(this);

            if (this.ClientInfo != "")
            {
                ClientPacketHandler.send_Property(this, "client_info", 0, true, this.ClientInfo);
            }


            ClientPacketHandler.send_QuestList(this);
            ClientPacketHandler.send_Packet625(this);
            ClientPacketHandler.send_Packet626(this);
            ClientPacketHandler.send_Packet627(this);
            ClientPacketHandler.send_Packet629(this);

            ClientPacketHandler.send_Packet631(this, 1);
            ClientPacketHandler.send_Packet631(this, 2);
            ClientPacketHandler.send_Packet631(this, 3);
            ClientPacketHandler.send_Packet631(this, 4);
            ClientPacketHandler.send_Packet631(this, 5);

            //PacketParser.send_Packet22(sid, 2);
            //PacketParser.send_Packet22(sid, 3);

            ClientPacketHandler.send_Property(this, "playtime", 0);
            ClientPacketHandler.send_Property(this, "playtime_limit1", 1080000);
            ClientPacketHandler.send_Property(this, "playtime_limit2", 1800000);

            ClientPacketHandler.send_LocationInfo(this);
            ClientPacketHandler.send_WeatherInfo(this);

            ClientPacketHandler.send_Property(this, "playtime", 0);

            //PacketParser.send_Packet22(sid, 4);

            //PacketParser.send_Packet08(sid, 1);

            ///ClientPacketHandler.send_GameTime(this);
            //PacketParser.send_Packet1101(this, 2);

            ///ClientPacketHandler.send_LocationInfo(this);

            ClientPacketHandler.send_Property(this, "stamina_regen", 30);

            ClientPacketHandler.send_UpdateStats(this, false);
            ClientPacketHandler.send_UpdateStats(this, true);

            return(true);
        }
コード例 #7
0
ファイル: Server.cs プロジェクト: ABooDY88HD/Tartarus-old
        private void Start()
        {
            GameDbConString = "Server=" + Settings.GameSqlIp + "; Database=" + Settings.GameSqlDatabase + "; Uid=" + Settings.GameSqlUsername + "; Pwd=" + Settings.GameSqlPassword + ";";
            UserDbConString = "Server=" + Settings.UserSqlIp + "; Database=" + Settings.UserSqlDatabase + "; Uid=" + Settings.UserSqlUsername + "; Pwd=" + Settings.UserSqlPassword + ";";

            // TODO : Put this in settings

            /* Urls
             * guild.url : http://guild.gamepower7.com/client/guild/login.aspx
             * guild_test_download.url : upload/client/guild/
             * web_download : guild.gamepower7.com
             * web_download_port : 0
             * shop.url : http://khroos.gamepower7.com/khroos/
             * ghelp_url : http://help.gamepower7.com/help/help-page/help-page.html
             * guild_icon_upload.ip : 95.211.112.10
             * guild_icon_upload.port : 4617
             * guild_icon_upload.url : http://guild.gamepower7.com/client/guild//iconupload.aspx
             */
            string[] urls = new string[]
            {
                "guild.url", "http://guild.gamepower7.com/client/guild/login.aspx",
                "guild_test_download.url", "upload/client/guild/",
                "web_download", "guild.gamepower7.com",
                "web_download_port", "0",
                "shop.url", "http://khroos.gamepower7.com/khroos/",
                "ghelp_url", "http://help.gamepower7.com/help/help-page/help-page.html",
                "guild_icon_upload.ip", "95.211.112.10",
                "guild_icon_upload.port", "4617",
                "guild_icon_upload.url", "http://guild.gamepower7.com/client/guild//iconupload.aspx"
            };
            UrlList = String.Join("|", urls);

            /* ************************* *
            * Test database connection
            * ************************* */
            ConsoleUtils.Write(ConsoleMsgType.Status, "Testing MySQL Connections...\n");
            Database db = new Database(GameDbConString);

            if (!db.Test())
            {
                ConsoleUtils.Write(ConsoleMsgType.Info, "Fix the errors and restart the server. Press any key to exit.\n");
                Console.ReadKey();
                return;
            }
            ConsoleUtils.Write(ConsoleMsgType.Status, "MySQL Connections Test OK\n");

            /* ************************* *
            * Load Game Data
            * ************************* */
            // Start Game Object Manager
            GObjectManager.Start();

            RegionMngr.Start();

            Script.LuaMain.Start();
            ItemDb.Start();
            StatsDb.Start();
            SkillDb.Start();
            MonsterDb.Start();
            Player.Start();
            Npc.Init();
            QuestDb.Start();

            /* ************************* *
            * Server Internal Timer
            * ************************* */
            // Server Timer
            this.GameTimer          = new Timer();
            this.GameTimer.Interval = 5000;             //ms
            this.GameTimer.Elapsed += (o, x) =>
            {
                GObjectManager.Update();
            };
            this.GameTimer.Start();

            /* ************************* *
            * Start Network Manager
            * ************************* */
            ConsoleUtils.Write(ConsoleMsgType.Status, "Initializing Network\n");

            UserJoinPool = new Dictionary <string, UserJoinData>();
            UserIds      = new Dictionary <string, int>();

            Network = new NetworkManager();
            Network.ConnectToAuthServer();
            Network.InitClientListener();

            ConsoleUtils.Write(ConsoleMsgType.Status, "Network Initialized\n");
        }