Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Drawing;
- using WzLib;
- namespace NpcReplacer
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private string RemovePreZerosFromId(string id)
- {
- string noZeros = id;
- while (noZeros[0] == Convert.ToChar("0"))
- {
- noZeros = noZeros.Substring(1);
- }
- return noZeros;
- }
- private WzImage GetImageFromImageArray(WzImage[] WzImages, string searchFor)
- {
- foreach (WzImage i in WzImages)
- {
- if (i.Name == searchFor)
- return i;
- }
- throw new Exception();
- }
- private IWzImageProperty GetPropertyFromPropertyArray(IWzImageProperty[] WzProps, string searchFor)
- {
- foreach (IWzImageProperty prop in WzProps)
- {
- if (prop.Name == searchFor)
- return prop;
- }
- throw new Exception();
- }
- private Bitmap CreateBitmapImage(string sImageText)
- {
- Bitmap objBmpImage = new Bitmap(1, 1);
- int intWidth = 0;
- int intHeight = 0;
- Font objFont = new Font("Arial", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
- Graphics objGraphics = Graphics.FromImage(objBmpImage);
- intWidth = (int)objGraphics.MeasureString(sImageText, objFont).Width;
- intHeight = (int)objGraphics.MeasureString(sImageText, objFont).Height;
- objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
- objGraphics = Graphics.FromImage(objBmpImage);
- objGraphics.Clear(Color.White);
- objGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
- objGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- objGraphics.DrawString(sImageText, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
- objGraphics.Flush();
- return (objBmpImage);
- }
- private void Npc()
- {
- WzFile f = new WzFile(@"D:\NpcOrg.wz", WzMapleVersion.GMS);
- WzFile _string = new WzFile(@"D:\HaxorStory\String.wz", WzMapleVersion.GMS);
- f.ParseWzFile();
- _string.ParseWzFile();
- WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Npc.img");
- if (!NpcImage.Parsed)
- NpcImage.ParseImage();
- foreach (WzImage image in f.WzDirectory.WzImages)
- {
- if (!image.Parsed)
- image.ParseImage();
- string npcId = RemovePreZerosFromId(image.Name.Split(Convert.ToChar("."))[0]);
- string npcName = "";
- try
- {
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- }
- catch
- {
- continue;
- }
- try
- {
- WzCanvasProperty standImage = (WzCanvasProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(image.WzProperties, "stand")).ExtendedProperty).WzProperties, "0")).ExtendedProperty;
- standImage.PngProperty.PNG = CreateBitmapImage(npcName);
- }
- catch
- {
- continue;
- }
- image.changed = true;
- }
- f.SaveToDisk(@"D:\NpcHax.wz");
- }
- private void Mob()
- {
- WzFile f = new WzFile(@"D:\MobOrg.wz", WzMapleVersion.GMS);
- WzFile _string = new WzFile(@"D:\HaxorStory\String.wz", WzMapleVersion.GMS);
- f.ParseWzFile();
- _string.ParseWzFile();
- WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Mob.img");
- if (!NpcImage.Parsed)
- NpcImage.ParseImage();
- foreach (WzImage image in f.WzDirectory.WzImages)
- {
- if (!image.Parsed)
- image.ParseImage();
- string npcId = RemovePreZerosFromId(image.Name.Split(Convert.ToChar("."))[0]);
- string npcName = "";
- try
- {
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- }
- catch
- {
- continue;
- }
- try
- {
- WzCanvasProperty standImage = (WzCanvasProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(image.WzProperties, "stand")).ExtendedProperty).WzProperties, "0")).ExtendedProperty;
- standImage.PngProperty.PNG = CreateBitmapImage(npcName);
- }
- catch
- {
- continue;
- }
- image.changed = true;
- }
- f.SaveToDisk(@"D:\MobHax.wz");
- }
- private string GetItemNameById(WzFile f, WzFile _string)
- {
- string npcName = "";
- try
- {
- WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Consume.img");
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- if (npcName != "")
- return npcName;
- }
- catch
- {
- }
- try
- {
- WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- if (npcName != "")
- return npcName;
- }
- catch
- {
- }
- try
- {
- WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- if (npcName != "")
- return npcName;
- }
- catch
- {
- }
- try
- {
- WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- if (npcName != "")
- return npcName;
- }
- catch
- {
- }
- try
- {
- WzImage NpcImage = GetImageFromImageArray(_string.WzDirectory.WzImages, "Etc.img");
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, "Etc")).ExtendedProperty).WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- if (npcName != "")
- return npcName;
- }
- catch
- {
- }
- }
- private void Item()
- {
- WzFile f = new WzFile(@"D:\ItemOrg.wz", WzMapleVersion.GMS);
- WzFile _string = new WzFile(@"D:\HaxorStory\String.wz", WzMapleVersion.GMS);
- f.ParseWzFile();
- _string.ParseWzFile();
- if (!NpcImage.Parsed)
- NpcImage.ParseImage();
- foreach (WzImage image in f.WzDirectory.WzImages)
- {
- if (!image.Parsed)
- image.ParseImage();
- string npcId = RemovePreZerosFromId(image.Name.Split(Convert.ToChar("."))[0]);
- string npcName = "";
- try
- {
- npcName = ((WzStringProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(NpcImage.WzProperties, npcId)).ExtendedProperty).WzProperties, "name")).Value;
- }
- catch
- {
- continue;
- }
- try
- {
- WzCanvasProperty standImage = (WzCanvasProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(((WzSubProperty)((WzExtendedProperty)GetPropertyFromPropertyArray(image.WzProperties, "stand")).ExtendedProperty).WzProperties, "0")).ExtendedProperty;
- standImage.PngProperty.PNG = CreateBitmapImage(npcName);
- }
- catch
- {
- continue;
- }
- image.changed = true;
- }
- f.SaveToDisk(@"D:\ItemHax.wz");
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- Npc();
- Mob();
- Item();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement