Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

WZ Add Custom Mobs

Experienced Elementalist
Joined
Feb 15, 2010
Messages
201
Reaction score
296
Here's some mobs i rip from other game.
They are all sprite sheets have non-uniform sized rectangles as the animation frames and use a portion of the image for credits, etc.But this way is different from WZ pic I need crop/split into individual frames for Maple use.

Elem8100 - Add Custom Mobs - RaGEZONE Forums


Elem8100 - Add Custom Mobs - RaGEZONE Forums


Elem8100 - Add Custom Mobs - RaGEZONE Forums
 
Experienced Elementalist
Joined
Nov 21, 2008
Messages
297
Reaction score
38
dem jpg artifacts with a white background yum

what are you asking? you want us to cut the sprites out?
 
Experienced Elementalist
Joined
Feb 15, 2010
Messages
201
Reaction score
296
guy! Please read my post carefully. This is 'developments' section and I even haven't asked any question.
I will do it myself.
 
Last edited:
Newbie Spellweaver
Joined
Feb 23, 2016
Messages
8
Reaction score
0
What game was the tomato ripped from? If you don't mind me asking.
 
Experienced Elementalist
Joined
Feb 15, 2010
Messages
201
Reaction score
296
Well,that game contains XML file for sprite's coordinate data.Now you can use image editing tool(e.g Photoshop) to cut the sprite.But i think cut it by manual is kinda dumb and slow.I decide to write a tool to do it.
Just google it i found some useful code and works fine for me.
Code:
procedure CropPNG(Source: TPNGImage; Left, Top, Width, Height: Integer; out Target: TPNGImage);
var
  IsAlpha: Boolean;
  Line: Integer;
begin
  if (Source.Width < (Left + Width)) or (Source.Height < (Top + Height)) then
    raise Exception.Create('Invalid position/size');
  Target := TPNGImage.CreateBlank(Source.Header.ColorType, Source.Header.BitDepth, Width, Height);
  IsAlpha := Source.Header.ColorType in [COLOR_GRAYSCALEALPHA, COLOR_RGBALPHA];
  for Line := 0 to Target.Height - 1 do
  begin
    if IsAlpha then
      CopyMemory(Target.AlphaScanline[Line], Ptr(LongInt(Source.AlphaScanline[Line + Top]) + LongInt(Left)), Target.Width);
    CopyMemory(Target.Scanline[Line], Ptr(LongInt(Source.Scanline[Line + Top]) + LongInt(Left * 3)), Target.Width * 3);
  end;
end;

Tool code:
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  DirName, AppPath: string;
  Xml: TXmlVerySimple;
  FrameNode, Iter: TXmlNode;
  X, Y, Width, Height: Integer;
  SpriteSheet: TPNGImage;
  Pngs: TPNGImage;
begin
  if OpenPictureDialog1.Execute then
  begin
    Memo1.Lines.Clear;
    AppPath := ExtractFilePath(Application.ExeName);
    DirName := LeftStr(ExtractFileName(OpenPictureDialog1.FileName), 5);
    ForceDirectories(AppPath + DirName);

    SpriteSheet := TPNGImage.Create;
    SpriteSheet.LoadFromFile(OpenPictureDialog1.FileName);

    Xml := TXmlVerySimple.Create;
    Xml.LoadFromFile(AppPath + DirName + '.xml');
    FrameNode := Xml.DocumentElement.Find('frame');
    for Iter in FrameNode.ChildNodes do
    begin
      X := Iter.Attributes['x'].ToInteger;
      Y := Iter.Attributes['y'].ToInteger;
      Width := Iter.Attributes['sx'].ToInteger;
      Height := Iter.Attributes['sy'].ToInteger;
      CropPNG(SpriteSheet, X, Y, Width, Height, Pngs);
      Pngs.SaveToFile(AppPath + DirName +'\'+ Iter.Name + '.png');
      Memo1.Lines.Add(AppPath + DirName +'\'+ Iter.Name + '.png');
    end;
    SpriteSheet.Free;
    Pngs.Free;
    xml.Free;
    ShowMessage('Save Sprites Completed');
   end;
end;
Elem8100 - Add Custom Mobs - RaGEZONE Forums



If you want to play the tool download here:
 
Junior Spellweaver
Joined
Aug 13, 2010
Messages
111
Reaction score
16
Well,that game contains XML file for sprite's coordinate data.Now you can use image editing tool(e.g Photoshop) to cut the sprite.But i think cut it by manual is kinda dumb and slow.I decide to write a tool to do it.
Just google it i found some useful code and works fine for me.
Code:
procedure CropPNG(Source: TPNGImage; Left, Top, Width, Height: Integer; out Target: TPNGImage);
var
  IsAlpha: Boolean;
  Line: Integer;
begin
  if (Source.Width < (Left + Width)) or (Source.Height < (Top + Height)) then
    raise Exception.Create('Invalid position/size');
  Target := TPNGImage.CreateBlank(Source.Header.ColorType, Source.Header.BitDepth, Width, Height);
  IsAlpha := Source.Header.ColorType in [COLOR_GRAYSCALEALPHA, COLOR_RGBALPHA];
  for Line := 0 to Target.Height - 1 do
  begin
    if IsAlpha then
      CopyMemory(Target.AlphaScanline[Line], Ptr(LongInt(Source.AlphaScanline[Line + Top]) + LongInt(Left)), Target.Width);
    CopyMemory(Target.Scanline[Line], Ptr(LongInt(Source.Scanline[Line + Top]) + LongInt(Left * 3)), Target.Width * 3);
  end;
end;

Tool code:
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  DirName, AppPath: string;
  Xml: TXmlVerySimple;
  FrameNode, Iter: TXmlNode;
  X, Y, Width, Height: Integer;
  SpriteSheet: TPNGImage;
  Pngs: TPNGImage;
begin
  if OpenPictureDialog1.Execute then
  begin
    Memo1.Lines.Clear;
    AppPath := ExtractFilePath(Application.ExeName);
    DirName := LeftStr(ExtractFileName(OpenPictureDialog1.FileName), 5);
    ForceDirectories(AppPath + DirName);

    SpriteSheet := TPNGImage.Create;
    SpriteSheet.LoadFromFile(OpenPictureDialog1.FileName);

    Xml := TXmlVerySimple.Create;
    Xml.LoadFromFile(AppPath + DirName + '.xml');
    FrameNode := Xml.DocumentElement.Find('frame');
    for Iter in FrameNode.ChildNodes do
    begin
      X := Iter.Attributes['x'].ToInteger;
      Y := Iter.Attributes['y'].ToInteger;
      Width := Iter.Attributes['sx'].ToInteger;
      Height := Iter.Attributes['sy'].ToInteger;
      CropPNG(SpriteSheet, X, Y, Width, Height, Pngs);
      Pngs.SaveToFile(AppPath + DirName +'\'+ Iter.Name + '.png');
      Memo1.Lines.Add(AppPath + DirName +'\'+ Iter.Name + '.png');
    end;
    SpriteSheet.Free;
    Pngs.Free;
    xml.Free;
    ShowMessage('Save Sprites Completed');
   end;
end;
Elem8100 - Add Custom Mobs - RaGEZONE Forums



If you want to play the tool download here:

WTF just 12 hours !! you can do it
 
Experienced Elementalist
Joined
Feb 15, 2010
Messages
201
Reaction score
296
Now calculate mob's origin,head,LT,RB coordinate data.

Code:
  for Iter2 in Iter.Find('point').ChildNodes do
      begin
        if Iter2.Attributes['name'] = 'c' then
          Origin.X := Iter2.Attributes['x'].ToInteger;
        if Iter2.Attributes['name'] = 'brow' then
        begin
          Brow.X := Iter2.Attributes['x'].ToInteger;
          Brow.Y := Iter2.Attributes['y'].ToInteger;
        end;
      end;

      Origin.Y := Height;
      Head.X := Brow.X - Origin.X;
      Head.Y := Brow.Y - Origin.Y;

      if Iter.HasChild('area') then
      begin
        Area.X := Iter.Find('area').FirstChild.Attributes['x'].ToInteger;
        Area.Y := Iter.Find('area').FirstChild.Attributes['y'].ToInteger;
        AreaS.X := Iter.Find('area').FirstChild.Attributes['sx'].ToInteger;
        AreaS.Y := Iter.Find('area').FirstChild.Attributes['sy'].ToInteger;
      end;

      LT.X := Area.X - Origin.X;
      LT.Y := Area.Y - Origin.Y;
      RB.X := (AreaS.X - Area.X) - Origin.X;
      RB.Y := (AreaS.Y - Area.Y) - Origin.Y;

Elem8100 - Add Custom Mobs - RaGEZONE Forums
 
Back
Top