Advertisement
Guest User

Untitled

a guest
May 6th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Drawing;
  10. using WzLib;
  11.  
  12. namespace NpcReplacer
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private string RemovePreZerosFromId(string id)
  22. {
  23. string noZeros = id;
  24. while (noZeros[0] == Convert.ToChar("0"))
  25. {
  26. noZeros = noZeros.Substring(1);
  27. }
  28. return noZeros;
  29. }
  30.  
  31. private WzImage GetImageFromImageArray(WzImage[] WzImages, string searchFor)
  32. {
  33. foreach (WzImage i in WzImages)
  34. {
  35. if (i.Name == searchFor)
  36. return i;
  37. }
  38. throw new Exception();
  39. }
  40.  
  41. private IWzImageProperty GetPropertyFromPropertyArray(IWzImageProperty[] WzProps, string searchFor)
  42. {
  43. foreach (IWzImageProperty prop in WzProps)
  44. {
  45. if (prop.Name == searchFor)
  46. return prop;
  47. }
  48. throw new Exception();
  49. }
  50.  
  51. private Bitmap CreateBitmapImage(string sImageText)
  52. {
  53. Bitmap objBmpImage = new Bitmap(1, 1);
  54. int intWidth = 0;
  55. int intHeight = 0;
  56. Font objFont = new Font("Arial", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
  57. Graphics objGraphics = Graphics.FromImage(objBmpImage);
  58. intWidth = (int)objGraphics.MeasureString(sImageText, objFont).Width;
  59. intHeight = (int)objGraphics.MeasureString(sImageText, objFont).Height;
  60. objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
  61. objGraphics = Graphics.FromImage(objBmpImage);
  62. objGraphics.Clear(Color.White);
  63. objGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  64. objGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  65. objGraphics.DrawString(sImageText, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
  66. objGraphics.Flush();
  67. return (objBmpImage);
  68. }
  69.  
  70. private void Npc()
  71. {
  72. WzFile f = new WzFile(@"D:\NpcOrg.wz", WzMapleVersion.GMS);
  73. WzFile _string = new WzFile(@"D:\HaxorStory\String.wz", WzMapleVersion.GMS);
  74. f.ParseWzFile();
  75. _string.ParseWzFile();
  76. WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Npc.img");
  77. if (!NpcImage.Parsed)
  78. NpcImage.ParseImage();
  79. foreach (WzImage image in f.WzDirectory.WzImages)
  80. {
  81. if (!image.Parsed)
  82. image.ParseImage();
  83. string npcId = RemovePreZerosFromId(image.Name.Split(Convert.ToChar("."))[0]);
  84. string npcName = "";
  85. try
  86. {
  87. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  88. }
  89. catch
  90. {
  91. continue;
  92. }
  93. try
  94. {
  95. WzCanvasProperty standImage = (WzCanvasProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(image.WzProperties, "stand")).ExtendedProperty).WzProperties, "0")).ExtendedProperty;
  96. standImage.PngProperty.PNG = CreateBitmapImage(npcName);
  97. }
  98. catch
  99. {
  100. continue;
  101. }
  102. image.changed = true;
  103. }
  104. f.SaveToDisk(@"D:\NpcHax.wz");
  105. }
  106.  
  107. private void Mob()
  108. {
  109. WzFile f = new WzFile(@"D:\MobOrg.wz", WzMapleVersion.GMS);
  110. WzFile _string = new WzFile(@"D:\HaxorStory\String.wz", WzMapleVersion.GMS);
  111. f.ParseWzFile();
  112. _string.ParseWzFile();
  113. WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Mob.img");
  114. if (!NpcImage.Parsed)
  115. NpcImage.ParseImage();
  116. foreach (WzImage image in f.WzDirectory.WzImages)
  117. {
  118. if (!image.Parsed)
  119. image.ParseImage();
  120. string npcId = RemovePreZerosFromId(image.Name.Split(Convert.ToChar("."))[0]);
  121. string npcName = "";
  122. try
  123. {
  124. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  125. }
  126. catch
  127. {
  128. continue;
  129. }
  130. try
  131. {
  132. WzCanvasProperty standImage = (WzCanvasProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(image.WzProperties, "stand")).ExtendedProperty).WzProperties, "0")).ExtendedProperty;
  133. standImage.PngProperty.PNG = CreateBitmapImage(npcName);
  134. }
  135. catch
  136. {
  137. continue;
  138. }
  139. image.changed = true;
  140. }
  141. f.SaveToDisk(@"D:\MobHax.wz");
  142. }
  143.  
  144. private string GetItemNameById(WzFile f, WzFile _string)
  145. {
  146. string npcName = "";
  147. try
  148. {
  149. WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Consume.img");
  150. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  151. if (npcName != "")
  152. return npcName;
  153. }
  154. catch
  155. {
  156. }
  157. try
  158. {
  159. WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
  160. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  161. if (npcName != "")
  162. return npcName;
  163. }
  164. catch
  165. {
  166. }
  167. try
  168. {
  169. WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
  170. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  171. if (npcName != "")
  172. return npcName;
  173. }
  174. catch
  175. {
  176. }
  177. try
  178. {
  179. WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
  180. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  181. if (npcName != "")
  182. return npcName;
  183. }
  184. catch
  185. {
  186. }
  187. try
  188. {
  189. WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
  190. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  191. if (npcName != "")
  192. return npcName;
  193. }
  194. catch
  195. {
  196. }
  197. }
  198.  
  199. private void Item()
  200. {
  201. WzFile f = new WzFile(@"D:\ItemOrg.wz", WzMapleVersion.GMS);
  202. WzFile _string = new WzFile(@"D:\HaxorStory\String.wz", WzMapleVersion.GMS);
  203. f.ParseWzFile();
  204. _string.ParseWzFile();
  205. if (!NpcImage.Parsed)
  206. NpcImage.ParseImage();
  207. foreach (WzImage image in f.WzDirectory.WzImages)
  208. {
  209. if (!image.Parsed)
  210. image.ParseImage();
  211. string npcId = RemovePreZerosFromId(image.Name.Split(Convert.ToChar("."))[0]);
  212. string npcName = "";
  213. try
  214. {
  215. npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
  216. }
  217. catch
  218. {
  219. continue;
  220. }
  221. try
  222. {
  223. WzCanvasProperty standImage = (WzCanvasProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(image.WzProperties, "stand")).ExtendedProperty).WzProperties, "0")).ExtendedProperty;
  224. standImage.PngProperty.PNG = CreateBitmapImage(npcName);
  225. }
  226. catch
  227. {
  228. continue;
  229. }
  230. image.changed = true;
  231. }
  232. f.SaveToDisk(@"D:\ItemHax.wz");
  233. }
  234.  
  235. private void Form1_Load(object sender, EventArgs e)
  236. {
  237. Npc();
  238. Mob();
  239. Item();
  240. }
  241. }
  242. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement