예제 #1
0
        public static void LoadNpcList(CServer server)
        {
            server.NumLoadedNpcs = 0;
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load("./Data/NpcList.xml");
            }
            catch (Exception ex)
            {
                Core.CLog(String.Format("Error: {0}", ex.Message));
            }
            XmlNode     root = doc.DocumentElement;
            XmlNodeList list = root.SelectNodes("/npclist/npc");

            for (int i = 0; i < list.Count; i++)
            {
                CNpc thisnpc = new CNpc();
                thisnpc.Position.pCurrent.x = int.Parse(list.Item(i).Attributes.Item(0).Value);
                thisnpc.Position.pCurrent.y = int.Parse(list.Item(i).Attributes.Item(1).Value);
                thisnpc.NpcFile             = list.Item(i).Attributes.Item(2).Value;
                server.NpcList.Add(thisnpc);
                server.NumLoadedNpcs++;
            }
            Core.CLog(String.Format("Loaded {0} NPC's from Database.", server.NumLoadedNpcs));
        }
예제 #2
0
        public void pak_SpawnNpc(CPlayer thisclient, CNpc thisnpc)
        {
            thisnpc.NpcInfo.CharID = mServer.GetMobID();
            OutPak.Clear();
            OutPak.SetShort(172, 0);
            OutPak.SetShort(0x0364, 4);
            OutPak.SetShort(30000, 6);
            OutPak.SetShort(thisnpc.Position.pCurrent.x, 12);
            OutPak.SetShort(thisnpc.Position.pCurrent.y, 14);
            OutPak.SetShort(thisnpc.NpcInfo.CharID, 16);
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(String.Format("./Data/Npc/{0}", thisnpc.NpcFile));
            }
            catch (Exception ex)
            {
                Core.CLog(String.Format("Error: {0}", ex.Message));
            }
            XmlNode     root = doc.DocumentElement;
            XmlNodeList list = root.SelectNodes("/npc/inventory/item");

            OutPak.SetString(root.Attributes.Item(0).Value, 18);
            if (int.Parse(root.Attributes.Item(2).Value).Equals(0))
            {
                OutPak.SetShort(120, 30);
            }
            OutPak.SetShort(int.Parse(root.Attributes.Item(1).Value), 34);
            for (int i = 0; i < list.Count; i++)
            {
                int   slotnum  = int.Parse(list.Item(i).Attributes.Item(0).Value);
                CItem thisitem = new CItem();
                thisitem.ItemID = int.Parse(list.Item(i).Attributes.Item(1).Value);
                thisitem.EF1    = int.Parse(list.Item(i).Attributes.Item(2).Value);
                thisitem.EFV1   = int.Parse(list.Item(i).Attributes.Item(3).Value);
                thisitem.EF2    = int.Parse(list.Item(i).Attributes.Item(4).Value);
                thisitem.EFV2   = int.Parse(list.Item(i).Attributes.Item(5).Value);
                thisitem.EF3    = int.Parse(list.Item(i).Attributes.Item(6).Value);
                thisitem.EFV3   = int.Parse(list.Item(i).Attributes.Item(7).Value);
                OutPak.SetShort(thisclient.GetItemIDwRefine(thisitem), (2 * slotnum) + 36);
                OutPak.SetByte(thisclient.GetAnctCode(thisitem), slotnum + 131);
            }
            OutPak.SetShort(thisnpc.NpcInfo.CharID, 66);
            OutPak.SetShort(int.Parse(root.Attributes.Item(3).Value), 100);
            OutPak.SetByte(1, 102);
            OutPak.SetByte(int.Parse(root.Attributes.Item(2).Value), 106);
            OutPak.SetShort(4, 107); // Move Speed
            OutPak.SetShort(100, 108);
            OutPak.SetShort(100, 110);
            OutPak.SetShort(100, 112);
            OutPak.SetShort(100, 114);
            OutPak.SetShort(int.Parse(root.Attributes.Item(4).Value), 116);
            OutPak.SetShort(int.Parse(root.Attributes.Item(5).Value), 118);
            OutPak.SetShort(int.Parse(root.Attributes.Item(6).Value), 120);
            OutPak.SetShort(int.Parse(root.Attributes.Item(7).Value), 122);
            OutPak.SetShort(0, 128); // Spawn Effect 2=tele effect
            thisclient.Client.encdec.Encrypt(OutPak, OutPak.dataBuffer, 172, thisclient.Client.Hash);
            thisclient.Client.SendPacket(OutPak, 172);
        }
예제 #3
0
 public void pak_DeleteNpcSpawn(CPlayer thisclient, CNpc thisnpc)
 {
     OutPak.Clear();
     OutPak.SetShort(16, 0);
     OutPak.SetShort(0x0165, 4);
     OutPak.SetShort(thisnpc.NpcInfo.CharID, 6);
     thisclient.Client.encdec.Encrypt(OutPak, OutPak.dataBuffer, 16, thisclient.Client.Hash);
     thisclient.Client.SendPacket(OutPak, 16);
 }
예제 #4
0
 public static bool isNpcVisible(CPlayer thisclient, CNpc thisnpc)
 {
     foreach (object npc in thisclient.vNpcs)
     {
         if (npc.Equals(thisnpc))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #5
0
 public bool VisionList(CPlayer thisclient)
 {
     foreach (object client in m_ClientList)
     {
         CClient otherclient = (CClient)client;
         int     distance    = Distance(thisclient.Position.pCurrent, otherclient.Player.Position.pCurrent);
         if (CVisionFunc.isVisible(thisclient, otherclient.Player))
         {
             if (distance < 50)
             {
                 thisclient.vPlayers.Add(otherclient.Player);
             }
             else
             {
                 thisclient.vPlayers.Remove(otherclient.Player);
                 Packets.pak_DeleteCharSpawn(thisclient, otherclient.Player);
             }
         }
         else
         {
             if (distance < 20)
             {
                 thisclient.vPlayers.Add(otherclient.Player);
                 Packets.pak_SpawnChar(thisclient, otherclient.Player);
             }
         }
     }
     foreach (object npc in NpcList)
     {
         CNpc thisnpc  = (CNpc)npc;
         int  distance = Distance(thisclient.Position.pCurrent, thisnpc.Position.pCurrent);
         if (CVisionFunc.isNpcVisible(thisclient, thisnpc))
         {
             if (distance < 50)
             {
                 thisclient.vNpcs.Add(thisnpc);
             }
             else
             {
                 thisclient.vNpcs.Remove(thisnpc);
                 Packets.pak_DeleteNpcSpawn(thisclient, thisnpc);
             }
         }
         else
         {
             if (distance < 20)
             {
                 thisclient.vNpcs.Add(thisnpc);
                 Packets.pak_SpawnNpc(thisclient, thisnpc);
             }
         }
     }
     return(true);
 }