Advertisement
Ketos52015

Untitled

Feb 10th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.58 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. using System;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Collections.Generic;
  9. using MYSQLCONNECTION = MySql.Data.MySqlClient.MySqlConnection;
  10.  
  11. namespace COServer.Database
  12. {
  13. public unsafe static class DataHolder
  14. {
  15. public static string ConnectionString;
  16. private static string MySqlUsername, MySqlPassword, MySqlDatabase, MySqlHost;
  17. public static void CreateConnection1(string user, string password, string database, string host)
  18. {
  19. MySqlUsername = user;
  20. MySqlHost = host;
  21. MySqlPassword = password;
  22. MySqlDatabase = database;
  23. ConnectionString = "Server=" + MySqlHost + ";Database='" + MySqlDatabase + "';Username='" + MySqlUsername + "';Password='" + MySqlPassword + "';Pooling=true; Max Pool Size = 900000; Min Pool Size = 5";
  24. }
  25. public static void CreateConnection(string user, string password, string database, string host)
  26. {
  27. var list = System.Configuration.ConfigurationManager.ConnectionStrings;
  28. ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[list.Count - 1].ConnectionString;
  29. }
  30. public static MYSQLCONNECTION MySqlConnection
  31. {
  32. get
  33. {
  34. MYSQLCONNECTION conn = new MYSQLCONNECTION();
  35. conn.ConnectionString = ConnectionString;
  36. return conn;
  37. }
  38. }
  39. static SafeDictionary<byte, string> ArcherStats = new SafeDictionary<byte, string>(130);
  40. static SafeDictionary<byte, string> NinjaStats = new SafeDictionary<byte, string>(130);
  41. static SafeDictionary<byte, string> WarriorStats = new SafeDictionary<byte, string>(130);
  42. static SafeDictionary<byte, string> TrojanStats = new SafeDictionary<byte, string>(130);
  43. static SafeDictionary<byte, string> TaoistStats = new SafeDictionary<byte, string>(130);
  44. static SafeDictionary<byte, string> MonkStats = new SafeDictionary<byte, string>(130);
  45. static SafeDictionary<byte, string> WindwalkerStats = new SafeDictionary<byte, string>(130);
  46. static SafeDictionary<byte, string> PirateStats = new SafeDictionary<byte, string>(130);
  47. static SafeDictionary<byte, string> BruceLeeStats = new SafeDictionary<byte, string>(130);
  48. public static void ReadStats()
  49. {
  50. string Path = Constants.DataHolderPath + "Stats.ini";
  51. IniFile IniFile = new IniFile(Path);
  52. for (byte lvl = 1; lvl < 122; lvl++)
  53. {
  54. string job = "Archer[" + lvl + "]";
  55. string Data = IniFile.ReadString("Stats", job);
  56. try
  57. {
  58. ArcherStats.Add(lvl, Data);
  59. job = "Ninja[" + lvl + "]";
  60. Data = IniFile.ReadString("Stats", job);
  61. NinjaStats.Add(lvl, Data);
  62. job = "Warrior[" + lvl + "]";
  63. Data = IniFile.ReadString("Stats", job);
  64. WarriorStats.Add(lvl, Data);
  65. job = "Trojan[" + lvl + "]";
  66. Data = IniFile.ReadString("Stats", job);
  67. TrojanStats.Add(lvl, Data);
  68. job = "Taoist[" + lvl + "]";
  69. Data = IniFile.ReadString("Stats", job);
  70. TaoistStats.Add(lvl, Data);
  71. job = "Windwalker[" + lvl + "]";
  72. Data = IniFile.ReadString("Stats", job);
  73. WindwalkerStats.Add(lvl, Data);
  74. job = "Monk[" + lvl + "]";
  75. Data = IniFile.ReadString("Stats", job);
  76. MonkStats.Add(lvl, Data);
  77. job = "BruceLee[" + lvl + "]";
  78. Data = IniFile.ReadString("Stats", job);
  79. BruceLeeStats.Add(lvl, Data);
  80. job = "Pirate[" + lvl + "]";
  81. Data = IniFile.ReadString("Stats", job);
  82. PirateStats.Add(lvl, Data);
  83. }
  84. catch
  85. {
  86. Console.WriteLine(Data);
  87. }
  88. }
  89. }
  90. public static ushort[] FindReviveSpot(ushort mapID)
  91. {
  92. IniFile IniFile = new IniFile(Constants.RevivePoints);
  93. string value = IniFile.ReadString(mapID.ToString(), "Value");
  94. if (value == String.Empty)
  95. return new ushort[] { 1002, 300, 278 };
  96.  
  97. if (value.Contains("L"))
  98. value = IniFile.ReadString(value.Remove(0, 7), "Value");
  99.  
  100. string[] split = value.Split(' ');
  101. List<ushort> values = new List<ushort>();
  102. try
  103. {
  104. values.Add(ushort.Parse(split[0]));
  105. values.Add(ushort.Parse(split[1]));
  106. values.Add(ushort.Parse(split[2]));
  107. }
  108. catch
  109. {
  110. Console.WriteLine("Revive spot with error: " + value);
  111. return new ushort[] { 1002, 300, 278 };
  112. }
  113. return values.ToArray();
  114. }
  115. public static void GetStats(byte inClass, byte inLevel, Client.GameState client)
  116. {
  117. string Class = "";
  118. inClass = (byte)((inClass / 10) * 10);
  119. switch (inClass)
  120. {
  121. case 10: Class = "Trojan"; break;
  122. case 20: Class = "Warrior"; break;
  123. case 40: Class = "Archer"; break;
  124. case 50: Class = "Ninja"; break;
  125. case 60: Class = "Monk"; break;
  126. case 70: Class = "Pirate"; break;
  127. case 80: Class = "BruceLee"; break;
  128. case 160: Class = "Windwalker"; break;
  129. default: Class = "Taoist"; break;
  130. }
  131. inLevel = Math.Max((byte)10, inLevel);
  132. inLevel = Math.Min((byte)120, inLevel);
  133. string[] Data = null;
  134. if (Class == "Trojan")
  135. Data = TrojanStats[inLevel].Split(',');
  136. else if (Class == "Warrior")
  137. Data = WarriorStats[inLevel].Split(',');
  138. else if (Class == "Archer")
  139. Data = ArcherStats[inLevel].Split(',');
  140. else if (Class == "Ninja")
  141. Data = NinjaStats[inLevel].Split(',');
  142. else if (Class == "Taoist")
  143. Data = TaoistStats[inLevel].Split(',');
  144. else if (Class == "Windwalker")
  145. Data = BruceLeeStats[inLevel].Split(',');
  146. else if (Class == "Monk")
  147. Data = MonkStats[inLevel].Split(',');
  148. else if (Class == "Pirate")
  149. Data = PirateStats[inLevel].Split(',');
  150. else if (Class == "BruceLee")
  151. Data = BruceLeeStats[inLevel].Split(',');
  152.  
  153. client.Player.Strength = Convert.ToUInt16(Data[0]);
  154. client.Player.Vitality = Convert.ToUInt16(Data[1]);
  155. client.Player.Agility = Convert.ToUInt16(Data[2]);
  156. client.Player.Spirit = Convert.ToUInt16(Data[3]);
  157. }
  158. public static ulong LevelExperience(byte Level)
  159. {
  160. return levelExperience[Math.Min(Math.Max(Level - 1, 0), 135)];
  161. }
  162. public static uint ProficiencyLevelExperience(byte Level)
  163. {
  164. return proficiencyLevelExperience[Math.Min(Level, (byte)20)];
  165. }
  166. public static uint StonePlusPoints(byte plus)
  167. {
  168. return StonePoints[Math.Min((int)plus, 8)];
  169. }
  170. public static uint ComposePlusPoints(byte plus)
  171. {
  172. return ComposePoints[Math.Min(plus, (byte)12)];
  173. }
  174. public static byte SteedSpeed(byte plus)
  175. {
  176. return _SteedSpeed[Math.Min(plus, (byte)12)];
  177. }
  178. public static ushort TalismanPlusPoints(byte plus)
  179. {
  180. return TalismanExtra[Math.Min(plus, (byte)9)];
  181. }
  182. public static ushort PurifyStabilizationPoints(byte plevel)
  183. {
  184. return purifyStabilizationPoints[Math.Min(plevel - 1, (byte)5)];
  185. }
  186. public static ushort RefineryStabilizationPoints(byte elevel)
  187. {
  188. return refineryStabilizationPoints[Math.Min(elevel - 1, (byte)4)];
  189. }
  190. static ushort[] purifyStabilizationPoints = new ushort[6] { 10, 30, 60, 100, 150, 200 };
  191. static ushort[] refineryStabilizationPoints = new ushort[5] { 10, 30, 70, 150, 270 };
  192. public static ushort[] Disguises = new ushort[] { 111, 224, 117, 152, 113, 833, 116, 245, 223, 112, 222, 114, 221, 115, 220 };
  193. static ushort[] StonePoints = new ushort[9] { 1, 10, 40, 120, 360, 1080, 3240, 9720, 29160 };
  194. static ushort[] ComposePoints = new ushort[13] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000, 0 };
  195. static byte[] _SteedSpeed = new byte[] { 0, 5, 10, 15, 20, 30, 40, 50, 65, 85, 90, 95, 100 };
  196. static ushort[] TalismanExtra = new ushort[10] { 0, 6, 30, 70, 240, 740, 2240, 6670, 20000, 60000 };
  197. static uint[] proficiencyLevelExperience = new uint[21] { 0, 1200, 68000, 250000, 640000, 1600000, 4000000, 10000000, 22000000, 40000000, 90000000, 95000000, 142500000, 213750000, 320625000, 480937500, 721406250, 1082109375, 1623164063, 2100000000, 0 };
  198. static ulong[] levelExperience = new ulong[139] { 120, 180, 240, 360, 600, 960, 1200, 2400, 3600, 8400, 12000, 14400, 18000, 21600, 22646, 32203, 37433, 47556, 56609, 68772, 70515, 75936, 97733, 114836, 120853, 123981, 126720, 145878, 173436, 197646, 202451, 212160, 244190, 285823, 305986, 312864, 324480, 366168, 433959, 460590, 506738, 569994, 728527, 850829, 916479, 935118, 940800, 1076593, 1272780, 1357994, 1384861, 1478400, 1632438, 1903104, 2066042, 2104924, 1921085, 2417202, 2853462, 3054574, 3111217, 3225600, 3810962, 4437896, 4880605, 4970962, 5107200, 5652518, 6579162, 6877991, 7100700, 7157657, 9106860, 10596398, 11220549, 11409192, 11424000, 12882952, 15172807, 15896990, 16163799, 16800000, 19230280, 22365208, 23819312, 24219528, 24864000, 27200077, 32033165, 33723801, 34291317, 34944000, 39463523, 45878567, 48924236, 49729220, 51072000, 55808379, 64870058, 68391931, 69537026, 76422968, 96950789, 112676755, 120090482, 121798280, 127680000, 137446887, 193715970, 408832150, 454674685, 461125885, 469189885, 477253885, 480479485, 485317885, 493381885, 580580046, 717424987, 282274058, 338728870, 406474644, 487769572, 585323487, 702388184, 842865821, 1011438985, 1073741823, 1073741823, 8589134588, 25767403764, 77302211292, 231906633876, 347859950814, 447859950814, 547859950814, 1174030000000, 1761040000000, 2641550000000 };
  199. }
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement