Jump to content
  • 0

Act editor remove all frames script


Question

10 answers to this question

Recommended Posts

  • 0
Posted

There are many ways to achieve that:

foreach (var action in act) {
	action.Frames = action.Frames.Take(1).ToList();
}

If you need more... "control" with indexes and which animations to remove exactly, you can do it this way too:

for (int aid = 0; aid < act.Actions.Count; aid++) {
	for (int fid = act.Actions[aid].Frames.Count - 1; fid >= 1; fid--) {
		act[aid].Frames.RemoveAt(fid);
	}
}

If you want to apply this to a batch of files, you can do it this way too:

var path = @"C:\Sprites\";

foreach (var file in Directory.GetFiles(path, "*.act")) {
	var actFile = new Act(file);
	
	actFile.Actions.ForEach(p => p.Frames = p.Frames.Take(1).ToList());
	actFile.Save(file);
}

 

  • 0
Posted
On 1/24/2022 at 11:41 AM, Tokei said:

There are many ways to achieve that:

foreach (var action in act) {
	action.Frames = action.Frames.Take(1).ToList();
}

If you need more... "control" with indexes and which animations to remove exactly, you can do it this way too:

for (int aid = 0; aid < act.Actions.Count; aid++) {
	for (int fid = act.Actions[aid].Frames.Count - 1; fid >= 1; fid--) {
		act[aid].Frames.RemoveAt(fid);
	}
}

If you want to apply this to a batch of files, you can do it this way too:

var path = @"C:\Sprites\";

foreach (var file in Directory.GetFiles(path, "*.act")) {
	var actFile = new Act(file);
	
	actFile.Actions.ForEach(p => p.Frames = p.Frames.Take(1).ToList());
	actFile.Save(file);
}

 

I can't make this script work, it is not running and no errors were also given. 

  • 0
Posted
2 hours ago, chibubong said:

I can't make this script work, it is not running and no errors were also given. 

What part is not working for you? It removes all frames except the first one for me.

  • 0
Posted
11 hours ago, antonigaming said:

Piggybacking on this question. How do you run such script on a whole batch?

var path = @"C:\test\";

foreach (var actFile in Directory.GetFiles(path, "*.act")) {
	var sprFile = actFile.ReplaceExtension(".spr");
	var act2 = new Act(actFile, sprFile);
	
	foreach (var action in act2) {
		action.Frames = action.Frames.Take(1).ToList();
	}
	
	act2.SaveWithSprite(actFile, sprFile);
}

 

  • 0
Posted (edited)

If anyone is looking to remove death animations here is the code

 

var path = @"C:\RO\data\sprite\test";

foreach (var actFile in Directory.GetFiles(path, "*.act")) {
    var sprFile = actFile.ReplaceExtension(".spr");
    var act2 = new Act(actFile, sprFile);
    
    for (int aid = 32; aid < act2.Actions.Count; aid++) {
        for (int fid = act2.Actions[aid].Frames.Count - 1; fid >= 1; fid--) {
        act2[aid].Frames.RemoveAt(fid);
           }
    }
    
    act2.SaveWithSprite(actFile, sprFile);
}

 

Edited by notmyproblem
  • 0
Posted
On 4/2/2023 at 8:26 PM, notmyproblem said:

If anyone is looking to remove death animations here is the code

 

var path = @"C:\RO\data\sprite\test";

foreach (var actFile in Directory.GetFiles(path, "*.act")) {
    var sprFile = actFile.ReplaceExtension(".spr");
    var act2 = new Act(actFile, sprFile);
    
    for (int aid = 32; aid < act2.Actions.Count; aid++) {
        for (int fid = act2.Actions[aid].Frames.Count - 1; fid >= 1; fid--) {
        act2[aid].Frames.RemoveAt(fid);
           }
    }
    
    act2.SaveWithSprite(actFile, sprFile);
}

 

What if I want to make the death animation faster and not totally removing it?

  • 0
Posted (edited)

The old script did not completely remove the death animation for me, so I modified it. not sure if it's optimal but it does the job for me. 

 

var path = @"C:\data\sprite\몬스터"; // Folder Path

foreach (var actFile in Directory.GetFiles(path, "*.act")) {
    var sprFile = actFile.ReplaceExtension(".spr");
    var act2 = new Act(actFile, sprFile);
    
    {
    act2.AnimationExecute(4, action => {
    action.Frames = new List<Frame> { new Frame() };});
    }
    
    act2.SaveWithSprite(actFile, sprFile);
}

 

Edited by reinmisaac
new script

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...