public static void H1(Client _client, byte[] packet) { _client.idtalking = Class5.smethod_9(new byte[] { packet[6], packet[7] }); int my_MapId = _client._My_MapId; _client.idnpctalking = Data.GetDataNpcOnMap(my_MapId, _client.idtalking, DataStructure.Type_NpcOnMap._NpcId); int dataNpcOnMap = Data.GetDataNpcOnMap(my_MapId, _client.idtalking, DataStructure.Type_NpcOnMap._SoLuong); checked { int num = _client._My_MapX - Data.GetDataNpcOnMap(my_MapId, _client.idtalking, DataStructure.Type_NpcOnMap._X_First); int num2 = _client._My_MapY - Data.GetDataNpcOnMap(my_MapId, _client.idtalking, DataStructure.Type_NpcOnMap._Y_First); int idnpctalking = _client.idnpctalking; if (idnpctalking != 16080 && idnpctalking != 16004 && idnpctalking != 16011) { if (idnpctalking != 16012) { if (!(-150 <= num & num <= 150 & -150 <= num2 & num2 <= 150)) { _client.EndTalk(); return; } if (dataNpcOnMap == 0) { _client.Typetalk = "NPC"; int step = _client.QuestGetDataNpc(my_MapId, _client.idtalking); if (!Data.GetDataTalkExits(my_MapId, _client.Typetalk, _client.idtalking, step)) { _client.Sendpacket("F44402000602"); _client.Sendpacket("F44411001401000000010103" + _client.idtalking.ToString("X2") + "000000000000C830"); return; } if (Data.GetDataTalkCount(my_MapId, _client.Typetalk, _client.idtalking, step) == 0) { _client.EndTalk(); return; } _client.Sendpacket("F44402000602"); _client.Sendpacket(Data.GetDataTalkString(my_MapId, _client.Typetalk, _client.idtalking, step, _client.talkcount + 1)); if ((double)my_MapId == Conversions.ToDouble("10817")) { FTalk.M18017(_client); return; } return; } else { if (dataNpcOnMap <= 0) { return; } DataStructure.Key_NpcOnMap key_NpcOnMap = Data.GetKey_NpcOnMap(my_MapId, _client.idtalking); if (!Data.NpcOnMap.ContainsKey(key_NpcOnMap)) { _client.EndTalk(); return; } DataStructure._NpcOnMap npcOnMap = Data.NpcOnMap[key_NpcOnMap]; if (_client._My_IdBattle > 0) { return; } int npcId = npcOnMap._NpcId; int delay = npcOnMap._Delay; if (delay != 0) { return; } switch (dataNpcOnMap) { case 1: { DataStructure.TeamDeffender teamdef = default(DataStructure.TeamDeffender); teamdef._id3 = npcId; _client._My_TalkingBattle = _client.idtalking; new TheBattle(_client._My_Id, teamdef, 4712); return; } case 2: case 4: return; case 3: { DataStructure.TeamDeffender teamdef2 = default(DataStructure.TeamDeffender); teamdef2._id2 = npcId; teamdef2._id3 = npcId; teamdef2._id4 = npcId; _client._My_TalkingBattle = _client.idtalking; new TheBattle(_client._My_Id, teamdef2, 4712); return; } case 5: { DataStructure.TeamDeffender teamdef3 = default(DataStructure.TeamDeffender); teamdef3._id1 = npcId; teamdef3._id2 = npcId; teamdef3._id3 = npcId; teamdef3._id4 = npcId; teamdef3._id5 = npcId; _client._My_TalkingBattle = _client.idtalking; new TheBattle(_client._My_Id, teamdef3, 4712); return; } default: return; } } } } if (-150 <= num & num <= 150 & -150 <= num2 & num2 <= 150) { _client.Typetalk = "NPC"; _client.Sendpacket("F44402000602"); _client.Sendpacket("F44411001401000000010603" + _client.idtalking.ToString("X2") + "0000000000000100"); } else { _client.EndTalk(); } } }
public static void NpcOnMapWalk() { int num = 0; checked { while (true) { Thread.Sleep(1000); num++; try { IEnumerator enumerator = Data._ListKeysNpcOnMap.GetEnumerator(); while (enumerator.MoveNext()) { object expr_23 = enumerator.Current; DataStructure.Key_NpcOnMap key_NpcOnMap = new DataStructure.Key_NpcOnMap(); DataStructure.Key_NpcOnMap key = (expr_23 != null) ? ((DataStructure.Key_NpcOnMap)expr_23) : key_NpcOnMap; DataStructure._NpcOnMap value = Data.NpcOnMap[key]; int delay = value._Delay; int idBattle = value._IdBattle; int mapId = value._MapId; int id = value._Id; if (!(delay == 0 & idBattle == 0)) { goto IL_401; } int coord = value._Coord; int x_First = value._X_First; int y_First = value._Y_First; int x = value._X; int y = value._Y; int num2 = x_First - coord; int maxValue = x_First + coord; if (num2 < 0) { num2 = x_First; } int num3 = y_First - coord; int maxValue2 = y_First + coord; if (num3 < 0) { num3 = y_First; } string text = ""; if (num >= 3) { try { try { IEnumerator enumerator2 = Server.ListView_Client.Items.GetEnumerator(); while (enumerator2.MoveNext()) { ListViewItem listViewItem = (ListViewItem)enumerator2.Current; try { Client client = (Client)listViewItem.Tag; if (client._socket.Connected) { int my_Id = client._My_Id; int my_MapId = client._My_MapId; int my_MapX = client._My_MapX; int my_MapY = client._My_MapY; int my_IdBattle = client._My_IdBattle; int my_IdLeader = client._My_IdLeader; if (my_MapId == mapId & my_IdBattle == 0 & (my_IdLeader == 0 | my_IdLeader == my_Id) & client._My_Logined == 1) { int num4 = (int)Math.Round(Math.Sqrt(unchecked(Math.Pow((double)checked(my_MapX - x_First), 2.0) + Math.Pow((double)checked(my_MapY - y_First), 2.0)))); if (num4 <= coord) { int arg_1F4_0 = (int)Math.Round(Math.Sqrt(unchecked(Math.Pow((double)checked(my_MapX - x), 2.0) + Math.Pow((double)checked(my_MapY - y), 2.0)))); value._X = my_MapX; value._Y = my_MapY; text = "F44408001602" + Class5.smethod_11(id) + Class5.smethod_11(my_MapX) + Class5.smethod_11(my_MapY); Server.SendToAllMapid(mapId, text); int soLuong = value._SoLuong; int npcId = value._NpcId; switch (soLuong) { case 1: { DataStructure.TeamDeffender teamdef = default(DataStructure.TeamDeffender); teamdef._id3 = npcId; Server.Clients[my_Id]._My_TalkingBattle = id; value._IdBattle = 1; new TheBattle(my_Id, teamdef, 4712); break; } case 3: { DataStructure.TeamDeffender teamdef2 = default(DataStructure.TeamDeffender); teamdef2._id2 = npcId; teamdef2._id3 = npcId; teamdef2._id4 = npcId; Server.Clients[my_Id]._My_TalkingBattle = id; value._IdBattle = 1; new TheBattle(my_Id, teamdef2, 4712); break; } case 5: { DataStructure.TeamDeffender teamdef3 = default(DataStructure.TeamDeffender); teamdef3._id1 = npcId; teamdef3._id2 = npcId; teamdef3._id3 = npcId; teamdef3._id4 = npcId; teamdef3._id5 = npcId; Server.Clients[my_Id]._My_TalkingBattle = id; value._IdBattle = 1; new TheBattle(my_Id, teamdef3, 4712); break; } } } } if (my_MapId == mapId) { int num5 = Data.random_3.Next(num2, maxValue); int num6 = Data.random_3.Next(num3, maxValue2); value._X = num5; value._Y = num6; if (text.Length == 0) { text = "F44408001602" + Class5.smethod_11(id) + Class5.smethod_11(num5) + Class5.smethod_11(num6); } client.Sendpacket(text); } } } catch (Exception expr_3C1) { ProjectData.SetProjectError(expr_3C1); ProjectData.ClearProjectError(); } } goto IL_41E; } finally { } } catch (Exception expr_3F3) { ProjectData.SetProjectError(expr_3F3); ProjectData.ClearProjectError(); goto IL_41E; } //goto IL_401; } IL_41E: Data.NpcOnMap[key] = value; continue; IL_401: if (delay >= 1) { value._IdBattle = 0; value._Delay--; goto IL_41E; } goto IL_41E; } } finally { } if (num >= 3) { num = 0; } } } }