Advertisement
botters

Untitled

Sep 28th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.26 KB | None | 0 0
  1. public class Booths
  2. {
  3. public enum BoothType
  4. {
  5. Npc = 0,
  6. Entity = 1
  7. }
  8. public class booth
  9. {
  10. public uint UID;
  11. public ushort Mesh = 100;
  12. public string Name;
  13. public ushort Map;
  14. public ushort X;
  15. public ushort Y;
  16. public List<string> Items;
  17. public BoothType Type;
  18. public string BotMessage = "Selling Items.[Boothing AI]";
  19. public uint Garment = 194300;
  20. public uint Head = 112259;
  21. public uint WeaponR = 601439;
  22. public uint WeaponL = 601439;
  23. public uint Armor = 135259;
  24. }
  25. public static SafeDictionary<uint, booth> Boooths = new SafeDictionary<uint, booth>();
  26. public static void Load()
  27. {
  28. string[] text = File.ReadAllLines(Constants.DataHolderPath + "/Booths.txt");
  29. booth booth = new booth();
  30. for (int x = 0; x < text.Length; x++)
  31. {
  32. string line = text[x];
  33. string[] split = line.Split('=');
  34. if (split[0] == "ID")
  35. {
  36. if (booth.UID == 0)
  37. booth.UID = uint.Parse(split[1]);
  38. else
  39. {
  40. if (!Boooths.ContainsKey(booth.UID))
  41. {
  42. Boooths.Add(booth.UID, booth);
  43. booth = new booth();
  44. booth.UID = uint.Parse(split[1]);
  45. }
  46. }
  47. }
  48. else if (split[0] == "Type")
  49. {
  50. booth.Type = (BoothType)byte.Parse(split[1]);
  51. }
  52. else if (split[0] == "Name")
  53. {
  54. booth.Name = split[1];
  55. }
  56.  
  57. else if (split[0] == "BotMessage")
  58. {
  59. booth.BotMessage = split[1];
  60. }
  61. else if (split[0] == "Garment")
  62. {
  63. booth.Garment = uint.Parse(split[1]);
  64. }
  65. else if (split[0] == "Head")
  66. {
  67. booth.Head = uint.Parse(split[1]);
  68. }
  69. else if (split[0] == "WeaponR")
  70. {
  71. booth.WeaponR = uint.Parse(split[1]);
  72. }
  73. else if (split[0] == "WeaponL")
  74. {
  75. booth.WeaponL = uint.Parse(split[1]);
  76. }
  77. else if (split[0] == "Armor")
  78. {
  79. booth.Armor = uint.Parse(split[1]);
  80. }
  81.  
  82.  
  83. else if (split[0] == "Mesh")
  84. {
  85. booth.Mesh = ushort.Parse(split[1]);
  86. }
  87. else if (split[0] == "Map")
  88. {
  89. booth.Map = ushort.Parse(split[1]);
  90. }
  91. else if (split[0] == "X")
  92. {
  93. booth.X = ushort.Parse(split[1]);
  94. }
  95. else if (split[0] == "Y")
  96. {
  97. booth.Y = ushort.Parse(split[1]);
  98. }
  99. else if (split[0] == "ItemAmount")
  100. {
  101. booth.Items = new List<string>(ushort.Parse(split[1]));
  102. }
  103. else if (split[0].Contains("Item") && split[0] != "ItemAmount")
  104. {
  105. string name = split[1];
  106. booth.Items.Add(name);
  107. }
  108. }
  109. if (!Boooths.ContainsKey(booth.UID))
  110. Boooths.Add(booth.UID, booth);
  111. CreateBooths();
  112. }
  113. public static void UpdateCoordonatesForAngle(ref ushort X, ref ushort Y, Enums.ConquerAngle angle)
  114. {
  115. sbyte xi = 0, yi = 0;
  116. switch (angle)
  117. {
  118. case Enums.ConquerAngle.North: xi = 1; yi = 1; break;
  119. case Enums.ConquerAngle.South: xi = -1; yi = -1; break;
  120. case Enums.ConquerAngle.East: xi = -1; yi = 1; break;
  121. case Enums.ConquerAngle.West: xi = 1; yi = -1; break;
  122. case Enums.ConquerAngle.NorthWest: xi = 1; break;
  123. case Enums.ConquerAngle.SouthWest: yi = -1; break;
  124. case Enums.ConquerAngle.NorthEast: yi = 1; break;
  125. case Enums.ConquerAngle.SouthEast: xi = -1; break;
  126. }
  127. X = (ushort)(X + xi);
  128. Y = (ushort)(Y + yi);
  129. }
  130.  
  131.  
  132. public static void CreateBooths()
  133. {
  134. foreach (var bo in Boooths.Values)
  135. {
  136.  
  137.  
  138. Game.ConquerStructures.Booth booth = new Game.ConquerStructures.Booth();
  139.  
  140. SobNpcSpawn Base = new SobNpcSpawn();
  141. Base.UID = bo.UID;
  142.  
  143.  
  144. if (Booth.Booths2.ContainsKey(Base.UID))
  145. Booth.Booths2.Remove(Base.UID);
  146. Booth.Booths2.Add(Base.UID, booth);
  147.  
  148. //if (Booth.Booths2.ContainsKey(Base.UID))
  149. // Booth.Booths2.Remove(Base.UID);
  150. //Booth.Booths2.Add(Base.UID, booth);
  151. Base.Mesh = bo.Mesh;
  152. // Base.Mesh = 400;
  153. Base.Type = Game.Enums.NpcType.Booth;
  154. Base.ShowName = true;
  155. Base.Name = bo.Name;
  156. Base.MapID = bo.Map;
  157. Base.X = bo.X;
  158. Base.Y = bo.Y;
  159. booth.Base = Base;
  160.  
  161. if (bo.Type == BoothType.Entity)
  162. {
  163. var c = new GameState(null);
  164. c.FakeLoad2(bo.UID, bo.Name);
  165.  
  166.  
  167. #region Equip
  168.  
  169. uint WeaponR = bo.WeaponR;
  170. uint WeaponL = bo.WeaponL;
  171. uint Armor = bo.Armor;
  172. uint Head = bo.Head;
  173. uint Garment = bo.Garment;
  174.  
  175. ConquerItem item7 = null;
  176. ClientEquip equip = null;
  177. if (WeaponR > 0)
  178. {
  179. Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[WeaponR];
  180. if (CIBI == null) return;
  181. item7 = new ConquerItem(true);
  182. item7.ID = WeaponR;
  183. item7.UID = AuthClient.nextID;
  184. AuthClient.nextID++;
  185. item7.Position = 4;
  186. item7.Durability = CIBI.Durability;
  187. item7.MaximDurability = CIBI.Durability;
  188. c.Equipment.Remove(4);
  189. if (c.Equipment.Objects[3] != null)
  190. {
  191. c.Equipment.Objects[3] = null;
  192. }
  193. c.Equipment.Add(item7);
  194. item7.Mode = Enums.ItemMode.Update;
  195. item7.Send(c);
  196. equip = new ClientEquip();
  197. equip.DoEquips(c);
  198. c.Send(equip);
  199. c.Equipment.UpdateEntityPacket();
  200.  
  201. }
  202. if (WeaponL > 0)
  203. {
  204. Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[WeaponL];
  205. if (CIBI == null) return;
  206. item7 = new ConquerItem(true);
  207. item7.ID = WeaponL;
  208. item7.UID = AuthClient.nextID;
  209. AuthClient.nextID++;
  210. item7.Position = 5;
  211. item7.Durability = CIBI.Durability;
  212. item7.MaximDurability = CIBI.Durability;
  213. c.Equipment.Remove(5);
  214. if (c.Equipment.Objects[4] != null)
  215. {
  216. c.Equipment.Objects[4] = null;
  217. }
  218. c.Equipment.Add(item7);
  219. item7.Mode = Enums.ItemMode.Update;
  220. item7.Send(c);
  221. equip = new ClientEquip();
  222. equip.DoEquips(c);
  223. c.Send(equip);
  224. c.Equipment.UpdateEntityPacket();
  225. }
  226.  
  227. if (Armor > 0)
  228. {
  229. Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[Armor];
  230. if (CIBI == null) return;
  231. item7 = new ConquerItem(true);
  232. item7.ID = Armor;
  233. item7.UID = AuthClient.nextID;
  234. AuthClient.nextID++;
  235. item7.Position = 3;
  236. item7.Durability = CIBI.Durability;
  237. item7.MaximDurability = CIBI.Durability;
  238. c.Equipment.Remove(3);
  239. if (c.Equipment.Objects[2] != null)
  240. {
  241. c.Equipment.Objects[2] = null;
  242. }
  243. c.Equipment.Add(item7);
  244. item7.Mode = Enums.ItemMode.Update;
  245. item7.Send(c);
  246. equip = new ClientEquip();
  247. equip.DoEquips(c);
  248. c.Send(equip);
  249. c.Equipment.UpdateEntityPacket();
  250.  
  251. }
  252.  
  253. if (Head > 0)
  254. {
  255. Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[Head];
  256. if (CIBI == null) return;
  257. item7 = new ConquerItem(true);
  258. item7.ID = Head;
  259. item7.UID = AuthClient.nextID;
  260. AuthClient.nextID++;
  261. item7.Position = 1;
  262. item7.Durability = CIBI.Durability;
  263. item7.MaximDurability = CIBI.Durability;
  264. c.Equipment.Remove(1);
  265. if (c.Equipment.Objects[0] != null)
  266. {
  267. c.Equipment.Objects[0] = null;
  268. }
  269. c.Equipment.Add(item7);
  270. item7.Mode = Enums.ItemMode.Update;
  271. item7.Send(c);
  272. equip = new ClientEquip();
  273. equip.DoEquips(c);
  274. c.Send(equip);
  275. c.Equipment.UpdateEntityPacket();
  276.  
  277. }
  278.  
  279. if (Garment > 0)
  280. {
  281. Database.ConquerItemBaseInformation CIBI = Database.ConquerItemInformation.BaseInformations[Garment];
  282. if (CIBI == null) return;
  283. item7 = new ConquerItem(true);
  284. item7.ID = Garment;
  285. item7.UID = AuthClient.nextID;
  286. AuthClient.nextID++;
  287. item7.Position = 9;
  288. item7.Durability = CIBI.Durability;
  289. item7.MaximDurability = CIBI.Durability;
  290. c.Equipment.Remove(9);
  291. if (c.Equipment.Objects[8] != null)
  292. {
  293. c.Equipment.Objects[8] = null;
  294. }
  295. c.Equipment.Add(item7);
  296. item7.Mode = Enums.ItemMode.Update;
  297. item7.Send(c);
  298. equip = new ClientEquip();
  299. equip.DoEquips(c);
  300. c.Send(equip);
  301. c.Equipment.UpdateEntityPacket();
  302. }
  303.  
  304. #endregion Equip
  305.  
  306. c.Entity.Facing = (Enums.ConquerAngle)(bo.Mesh % 10);
  307. UpdateCoordonatesForAngle(ref bo.X, ref bo.Y, c.Entity.Facing);
  308. c.Entity.X = bo.X;
  309. c.Entity.Y = bo.Y;
  310. c.Entity.MapID = bo.Map;
  311. c.Booth = booth;
  312. c.Booth.HawkMessage = new Message(bo.BotMessage, Message.HawkMessage);
  313. c.Entity.Action = Enums.ConquerAction.Sit;
  314. c.Send(new Data(true) { ID = Data.ChangeAction, UID = c.Entity.UID, dwParam = 0 });
  315.  
  316. var data = new Data(true);
  317. data.UID = c.Entity.UID;
  318. data.dwParam = Base.UID;
  319. data.wParam1 = Base.X;
  320. data.wParam2 = Base.Y;
  321. data.ID = Data.OwnBooth;
  322. c.Send(data);
  323. Base.Owner = c;
  324. }
  325. else
  326. {
  327. if (Kernel.Maps[bo.Map].Npcs.ContainsKey(Base.UID))
  328. Kernel.Maps[bo.Map].Npcs.Remove(Base.UID);
  329. Kernel.Maps[bo.Map].Npcs.Add(Base.UID, Base);
  330. }
  331.  
  332. for (int i = 0; i < bo.Items.Count; i++)
  333. {
  334. var line = bo.Items[i].Split(new string[] { "@@", "@" }, StringSplitOptions.RemoveEmptyEntries);
  335. #region booth
  336. Game.ConquerStructures.BoothItem item = new Game.ConquerStructures.BoothItem();
  337.  
  338. item.Item = new ConquerItem(true);
  339. item.Item.UID = AuthClient.nextID;
  340. AuthClient.nextID++;
  341. item.Item.ID = uint.Parse(line[0]);
  342. if (line.Length >= 2)
  343. item.Cost = uint.Parse(line[1]);
  344. if (line.Length >= 3)
  345. item.Item.Plus = byte.Parse(line[2]);
  346. if (line.Length >= 4)
  347. item.Item.Enchant = byte.Parse(line[3]);
  348. if (line.Length >= 5)
  349. item.Item.Bless = byte.Parse(line[4]);
  350. if (line.Length >= 6)
  351. item.Item.SocketOne = (Enums.Gem)byte.Parse(line[5]);
  352. if (line.Length >= 7)
  353. item.Item.SocketTwo = (Enums.Gem)byte.Parse(line[6]);
  354. if (line.Length >= 8)
  355. item.Item.StackSize = ushort.Parse(line[7]);
  356.  
  357. Database.ConquerItemBaseInformation CIBI = null;
  358. CIBI = Database.ConquerItemInformation.BaseInformations[item.Item.ID];
  359. if (CIBI == null)
  360. break;
  361. item.Item.Durability = CIBI.Durability;
  362. item.Item.MaximDurability = CIBI.Durability;
  363. item.Cost_Type = Game.ConquerStructures.BoothItem.CostType.ConquerPoints;
  364. booth.ItemList.Add(item.Item.UID, item);
  365. #endregion
  366. }
  367.  
  368. }
  369. VenusProject.Console.WriteLine("" + Booth.Booths2.Count + " New Booths Loaded.");
  370. }
  371. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement