Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Conquer_Online_Server.Database
  7. {
  8. using MYSQLCOMMAND = MySql.Data.MySqlClient.MySqlCommand;
  9. using MYSQLREADER = MySql.Data.MySqlClient.MySqlDataReader;
  10. using MYSQLCONNECTION = MySql.Data.MySqlClient.MySqlConnection;
  11. public static class DataHolder
  12. {
  13. public static string Host;
  14. public static string Username;
  15. public static string Password;
  16. public static string Database;
  17. //string ConfigFileName = "ScorpenProjects.ini";
  18. //IniFile IniFile = new IniFile(ConfigFileName);
  19. private static string ConnectionString;
  20.  
  21. public static void ScorpenConnection()
  22. {
  23. var list = System.Configuration.ConfigurationManager.ConnectionStrings;
  24. ConnectionString =
  25. System.Configuration.ConfigurationManager.ConnectionStrings[list.Count - 1].ConnectionString;
  26. }
  27.  
  28. public static MYSQLCONNECTION MySqlConnection
  29. {
  30. get
  31. {
  32. MYSQLCONNECTION conn = new MYSQLCONNECTION();
  33. conn.ConnectionString = ConnectionString;
  34. return conn;
  35. }
  36. }
  37. public static void CreateConnection(string host = "localhost", string username = "root")
  38. {
  39. //End Code Connection in IP 46.105.155.107
  40. ConnectionString = "Server=" + host + ";Port=3306;Database=;Uid=" + username + ";Password=;Persist Security Info=True;Pooling=true; Min Pool Size = 32; Max Pool Size = 300;";
  41.  
  42. }
  43. private static SafeDictionary<byte, string> ArcherStats = new SafeDictionary<byte, string>(130);
  44. private static SafeDictionary<byte, string> NinjaStats = new SafeDictionary<byte, string>(130);
  45. private static SafeDictionary<byte, string> WarriorStats = new SafeDictionary<byte, string>(130);
  46. private static SafeDictionary<byte, string> TrojanStats = new SafeDictionary<byte, string>(130);
  47. private static SafeDictionary<byte, string> TaoistStats = new SafeDictionary<byte, string>(130);
  48. private static SafeDictionary<byte, string> MonkStats = new SafeDictionary<byte, string>(130);
  49. private static SafeDictionary<byte, string> BruceLee = new SafeDictionary<byte, string>(130);
  50. private static SafeDictionary<byte, string> WindWalker = new SafeDictionary<byte, string>(130);
  51. public static bool IsTrojan(byte Job)
  52. {
  53. return Job >= 10 && Job <= 15;
  54. }
  55. public static bool IsWarrior(byte Job)
  56. {
  57. return Job >= 20 && Job <= 25;
  58. }
  59. public static bool IsArcher(byte Job)
  60. {
  61. return Job >= 40 && Job <= 45;
  62. }
  63. public static bool IsNinja(byte Job)
  64. {
  65. return Job >= 50 && Job <= 55;
  66. }
  67. public static bool IsMonk(byte Job)
  68. {
  69. return Job >= 60 && Job <= 65;
  70. }
  71. public static bool IsPirate(byte Job)
  72. {
  73. return Job >= 70 && Job <= 75;
  74. }
  75. public static bool IsWather(byte Job)
  76. {
  77. return Job >= 100 && Job <= 135;
  78. }
  79. public static bool IsFire(byte Job)
  80. {
  81. return Job >= 140 && Job <= 145;
  82. }
  83. public static bool IsTaoist(byte Job)
  84. {
  85. return Job >= 100 && Job <= 145;
  86. }
  87. public static bool IsWindwalker(byte Job)
  88. {
  89. return Job >= 160 && Job <= 165;
  90. }
  91. public static void ReadStats()
  92. {
  93. string Path = Constants.DataHolderPath + "Stats.ini";
  94. IniFile IniFile = new IniFile(Path);
  95.  
  96. for (byte lvl = 1; lvl < 122; lvl++)
  97. {
  98. string job = "Archer[" + lvl + "]";
  99. string Data = IniFile.ReadString("Stats", job);
  100. try
  101. {
  102. ArcherStats.Add(lvl, Data);
  103. job = "Ninja[" + lvl + "]";
  104. Data = IniFile.ReadString("Stats", job);
  105. NinjaStats.Add(lvl, Data);
  106. job = "Warrior[" + lvl + "]";
  107. Data = IniFile.ReadString("Stats", job);
  108. WarriorStats.Add(lvl, Data);
  109. job = "Trojan[" + lvl + "]";
  110. Data = IniFile.ReadString("Stats", job);
  111. TrojanStats.Add(lvl, Data);
  112. job = "Taoist[" + lvl + "]";
  113. Data = IniFile.ReadString("Stats", job);
  114. TaoistStats.Add(lvl, Data);
  115. job = "Monk[" + lvl + "]";
  116. Data = IniFile.ReadString("Stats", job);
  117. MonkStats.Add(lvl, Data);
  118. job = "BruceLee[" + lvl + "]";
  119. Data = IniFile.ReadString("Stats", job);
  120. BruceLee.Add(lvl, Data);
  121. job = "Windwalker[" + lvl + "]";
  122. Data = IniFile.ReadString("Stats", job);
  123. WindWalker.Add(lvl, Data);
  124. }
  125. catch
  126. {
  127. Console.WriteLine(Data);
  128. }
  129. }
  130. }
  131. public static ushort[] FindReviveSpot(ushort mapID)
  132. {
  133. IniFile IniFile = new IniFile(Constants.RevivePoints);
  134. string value = IniFile.ReadString(mapID.ToString(), "Value");
  135. if (value == String.Empty)
  136. return new ushort[] { 1002, 302, 280 };
  137.  
  138. if (value.Contains("L"))
  139. value = IniFile.ReadString(value.Remove(0, 7), "Value");
  140.  
  141. string[] split = value.Split(' ');
  142. List<ushort> values = new List<ushort>();
  143. try
  144. {
  145. values.Add(ushort.Parse(split[0]));
  146. values.Add(ushort.Parse(split[1]));
  147. values.Add(ushort.Parse(split[2]));
  148. }
  149. catch
  150. {
  151. Console.WriteLine("Revive spot with error: " + value);
  152. return new ushort[] { 1002, 302, 280 };
  153. }
  154. return values.ToArray();
  155. }
  156. public static void GetStats(byte inClass, byte inLevel, Client.GameState client)
  157. {
  158. string Class = "";
  159. inClass = (byte)((inClass / 10) * 10);
  160. switch (inClass)
  161. {
  162. case 10:
  163. Class = "Trojan";
  164. break;
  165. case 20:
  166. Class = "Warrior";
  167. break;
  168. case 40:
  169. Class = "Archer";
  170. break;
  171. case 50:
  172. Class = "Ninja";
  173. break;
  174. case 60:
  175. Class = "Monk";
  176. break;
  177. case 70:
  178. Class = "Pirate";
  179. break;
  180. case 160: Class = "Windwalker";
  181. break;
  182. case 80:
  183. Class = "BruceLee";
  184. break;
  185.  
  186. default:
  187. Class = "Taoist";
  188. break;
  189. }
  190. inLevel = Math.Max((byte)10, inLevel);
  191. inLevel = Math.Min((byte)120, inLevel);
  192. string[] Data = null;
  193. if (Class == "Trojan")
  194. Data = TrojanStats[inLevel].Split(',');
  195. else if (Class == "Warrior")
  196. Data = WarriorStats[inLevel].Split(',');
  197. else if (Class == "Archer")
  198. Data = ArcherStats[inLevel].Split(',');
  199. else if (Class == "Ninja")
  200. Data = NinjaStats[inLevel].Split(',');
  201. else if (Class == "Taoist")
  202. Data = TaoistStats[inLevel].Split(',');
  203. else if (Class == "Monk")
  204. Data = MonkStats[inLevel].Split(',');
  205. else if (Class == "Pirate")
  206. Data = MonkStats[inLevel].Split(',');
  207. else if (Class == "Windwalker")
  208. Data = WindWalker[inLevel].Split(',');
  209. else if (Class == "BruceLee")
  210. Data = BruceLee[inLevel].Split(',');
  211. client.Entity.Strength = Convert.ToUInt16(Data[0]);
  212. client.Entity.Vitality = Convert.ToUInt16(Data[1]);
  213. client.Entity.Agility = Convert.ToUInt16(Data[2]);
  214. client.Entity.Spirit = Convert.ToUInt16(Data[3]);
  215. }
  216.  
  217. public static ulong LevelExperience(byte Level)
  218. {
  219. return levelExperience[Math.Min(Math.Max(Level - 1, 0), 135)];
  220. }
  221.  
  222. public static uint ProficiencyLevelExperience(byte Level)
  223. {
  224. return proficiencyLevelExperience[Math.Min(Level, (byte)20)];
  225. }
  226.  
  227. private static uint[] proficiencyLevelExperience = new uint[21]
  228. {
  229. 0, 1200, 68000, 250000, 640000, 1600000, 4000000, 10000000, 22000000, 40000000, 90000000, 95000000, 142500000,
  230. 213750000, 320625000, 480937500, 721406250, 1082109375, 1623164063, 2100000000, 0
  231. };
  232.  
  233. private static ulong[] levelExperience = new ulong[139]
  234. {
  235. 120, 180, 240, 360, 600, 960, 1200, 2400, 3600, 8400, 12000, 14400, 18000, 21600, 22646, 32203, 37433, 47556,
  236. 56609, 68772, 70515, 75936, 97733, 114836, 120853, 123981, 126720, 145878, 173436, 197646, 202451, 212160,
  237. 244190, 285823, 305986, 312864, 324480, 366168, 433959, 460590, 506738, 569994, 728527, 850829, 916479,
  238. 935118, 940800, 1076593, 1272780, 1357994, 1384861, 1478400, 1632438, 1903104, 2066042, 2104924, 1921085,
  239. 2417202, 2853462, 3054574, 3111217, 3225600, 3810962, 4437896, 4880605, 4970962, 5107200, 5652518, 6579162,
  240. 6877991, 7100700, 7157657, 9106860, 10596398, 11220549, 11409192, 11424000, 12882952, 15172807, 15896990,
  241. 16163799, 16800000, 19230280, 22365208, 23819312, 24219528, 24864000, 27200077, 32033165, 33723801, 34291317,
  242. 34944000, 39463523, 45878567, 48924236, 49729220, 51072000, 55808379, 64870058, 68391931, 69537026, 76422968,
  243. 96950789, 112676755, 120090482, 121798280, 127680000, 137446887, 193715970, 408832150, 454674685, 461125885,
  244. 469189885, 477253885, 480479485, 485317885, 493381885, 580580046, 717424987, 282274058, 338728870, 406474644,
  245. 487769572, 585323487, 702388184, 842865821, 1011438985, 1073741823, 1073741823, 8589134588, 25767403764,
  246. 77302211292, 231906633876, 347859950814, 447859950814, 547859950814, 1174030000000, 1761040000000,
  247. 2641550000000
  248. };
  249.  
  250. public static uint StonePlusPoints(byte plus)
  251. {
  252. return StonePoints[Math.Min((int)plus, 8)];
  253. }
  254.  
  255. public static uint ComposePlusPoints(byte plus)
  256. {
  257. return ComposePoints[Math.Min(plus, (byte)12)];
  258. }
  259.  
  260. public static byte SteedSpeed(byte plus)
  261. {
  262. return _SteedSpeed[Math.Min(plus, (byte)12)];
  263. }
  264.  
  265. public static ushort TalismanPlusPoints(byte plus)
  266. {
  267. return TalismanExtra[Math.Min(plus, (byte)9)];
  268. }
  269.  
  270. public static ushort PurifyStabilizationPoints(byte plevel)
  271. {
  272. return purifyStabilizationPoints[Math.Min(plevel - 1, (byte)5)];
  273. }
  274.  
  275. private static ushort[] purifyStabilizationPoints = new ushort[6] { 10, 30, 60, 100, 150, 200 };
  276.  
  277. public static ushort RefineryStabilizationPoints(byte elevel)
  278. {
  279. return refineryStabilizationPoints[Math.Min(elevel - 1, (byte)4)];
  280. }
  281.  
  282. private static ushort[] refineryStabilizationPoints = new ushort[5] { 10, 30, 70, 150, 270 };
  283.  
  284. public static ushort[] Disguises = new ushort[] { 111, 224, 117, 152, 113, 833, 116, 245, 223, 112, 222, 114, 221, 115, 220 };
  285.  
  286. private static ushort[] StonePoints = new ushort[9] { 1, 10, 40, 120, 360, 1080, 3240, 9720, 29160 };
  287.  
  288. private static ushort[] ComposePoints = new ushort[13] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000, 0 };
  289.  
  290. private static byte[] _SteedSpeed = new byte[] { 0, 5, 10, 15, 20, 30, 40, 50, 65, 85, 90, 95, 100 };
  291. private static ushort[] TalismanExtra = new ushort[10] { 0, 6, 30, 70, 240, 740, 2240, 6670, 20000, 60000 };
  292. }
  293. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement