I need help making my first character PK3...

SuperPhanto

Bad at every videogame ever
Hello! I am trying to make Sonic from the cancelled saturn game "Sonic Xtreme." I'm going with the name XSonic for the skin. I am aware that this idea is not original, but I've thought about some ways I can set it apart from any lazy sprite rip that has been done before.

My first idea is to use the 2.2's new feature of extending the number of frames in animations to give XSonic's animations the same number of frames as they were intended to have. Trouble is, even though I have all the sprites necessary to make this happen, I don't know how to make use of this new feature, and at the time of writing this, the wiki hasn't been updated to my knowledge.

My second Idea was for his ability, which is an artistic interpretation of the ability Sonic was to have in Sonic Xtreme: the Spin Slash. Not much is known about this ability, other than it's name and what it looks like.
d9tivj1-82e5945b-de14-4c6c-9dc0-19b1a032d717.gif

My idea was to make it be a powerful ability with a risk/reward factor to it. Basically, it would make XSonic fall at half speed, pierce enemies, and break certain walls or floors. However, when you land on a surface, XSonic will get stuck in the surface, and will have to jump out in the spring animation, which leaves him completely vulnerable. At the same time, you can use this to your advantage to reach new heights by sticking to a wall and performing one wall jump. This is something that sounds like it would be hard to program, but I'll cross that bridge when I come to it. For now, I just need to know how to edit character's animations.

Thank you in advance for your consideration.
 
Last edited:
Though in fairness, I wasn't going to give Xtreme any special ability, I just slapped multiability thok on him and called it a day since I pictured him as a companion piece to UglyKnux.

Yeah, I see the thought process, but the thing about that is I'm not sure that simply having multi-thok and smooth animations would pass the review process here on the message board for submissions. That's why I took to the internet to find out if sonic xtreme was going to have it's own ability, and that's when learned about the Spin Slash. Some sources said it was an upgraded Spindash, but that theory falls apart in this screenshot, showing Sonic using it in the air during the boss fight with Fang:
nack3.jpg

I didn't think it would be any different from the Insta-Shield in Sonic 3, but I think that having it be different would help make this character unique.

But now that you mention that you were working on something similar, we could help each other if you want?
 
You already have all the sprites and that's all I have right now so I can't help you there.

Instead, I'll answer your question about animations. It's quite simple, really. The prefix no longer indicates the character (the waiting animation is no longer CHARB* and CHARC*) but now indicates the animation (a two-frame waiting animation would be WAITA* and WAITB*). So all you have to do is have more sprites using the prefix and that will automatically make the animation last longer.

If you check the official characters (they're in player.dta in the same folder as the game exe), you'll see they only have STNDA*. To make the standing animation longer, you add more sprites with the same prefix. So you have STNDA*, STNDB*, STNDC*, STNDD*, STNDE*, STNDF*, STNDG*, STNDH* and STNDI*. The game takes care of the rest on its own.

What it looks like in the editor
In-game

For walking, just stick in the 16 sprites for walking with the appropiate prefix and such (WALK**) and the game will use them all for the walking animation by itself. And the same applies to all the other animations (RUN_**, ROLL**, etc).
 
Alright, So after I imported all the animations, I realized something. The Animations are moving at halve the speed they should be, sometimes even slower. I tried messing around with SOC, but that changed the speed of every other character, too. After spending hours on Lua trying to get the same effect and getting not even close, I gave up trying to figure this out on my own.

This is the closest I got to is being able to do something, but all it does is freeze the animation for these states on XSonic Specifically.
Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if (player.mo and player.mo.skin == "sonicxt")
			if (player.mo.state == S_PLAY_STND)
				state.frame = 16384 //FF_ANIMATE
				player.mo.anim_duration = 4
			elseif (player.mo.state == S_PLAY_WAIT)
				state.frame = 16384 //FF_ANIMATE
				player.mo.anim_duration = 4
			elseif (player.mo.state == S_PLAY_WALK)
				state.frame = 16384 //FF_ANIMATE
				player.mo.anim_duration = 3
			elseif (player.mo.state == S_PLAY_RUN)
				state.frame = 16384 //FF_ANIMATE
				player.mo.anim_duration = 2
			elseif (player.mo.state == S_PLAY_ROLL)
				state.frame = 16384 //FF_ANIMATE
				player.mo.anim_duration = 1
			else
				continue
			end
		end
	end
end)
 
First, a little tip—you don't need to type out 16384, the script will parse FF_ANIMATE for you! However, you shouldn't need to be changing the frames for default states, so I would remove those lines. From what context I can see, I imagine they would print a warning in your console anyway.

The issue you're having is: player.mo.anim_duration counts down until it hits 0, at which point it will change the character's frame and reset itself to count down again. ThinkFrame functions are called every frame, so you're continuously setting player.mo.anim_counter to a nonzero value every frame, preventing it from counting all the way down. You need to make sure your custom anim_duration count is only set when the character's frame changes, or when their current anim_duration value is greater than the value you want to set it to.
 
You need to make sure your custom anim_duration count is only set when the character's frame changes, or when their current anim_duration value is greater than the value you want to set it to.
Okay, That makes sense. Doing that did work for S_PLAY_STND and S_PLAY_WAIT, but nothing else. I am guessing that S_PLAY_WALK, S_PLAY_RUN, and S_PLAY_ROLL don't have FF_ANIMATE set to them. This is my reasoning behind that conclusion: The Wiki states, "If mobj.frame currently has the frame flag FF_ANIMATE set, this is the duration in tics between each frame in the state's animation. Otherwise, this has no effect on the Object's animation."
Here's what I have
Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if (player.mo and player.mo.skin == "sonicxt")
			if (player.mo.state == S_PLAY_STND)
				if (player.mo.anim_duration > 2)
					player.mo.anim_duration = 2
				end
			elseif (player.mo.state == S_PLAY_WAIT)
				if (player.mo.anim_duration > 4)
					player.mo.anim_duration = 4
				end
			elseif (player.mo.state == S_PLAY_WALK)
				if (player.mo.anim_duration > 3)
					player.mo.anim_duration = 3
				end
			elseif (player.mo.state == S_PLAY_RUN)
				if (player.mo.anim_duration > 2)
					player.mo.anim_duration = 2
				end
			elseif (player.mo.state == S_PLAY_ROLL)
				if (player.mo.anim_duration > 1)
					player.mo.anim_duration = 1
				end
			else
				continue
			end
		end
	end
end)
 
That's correct! S_PLAY_WALK, S_PLAY_RUN, S_PLAY_ROLL, and many other player states don't use FF_ANIMATE. Instead, they loop into themselves—so, if the player enters S_PLAY_WALK, their frame is set to A, and once the state's duration is over, it re-enters S_PLAY_WALK and switches to frame B, so on and so forth. To shorten the duration of these states, simply shorten player.mo.tics in the same manner as player.mo.anim_duration.

While the wiki is still being updated, you can view the actual hardcoded state definitions over on GitLab: https://git.magicalgirl.moe/STJr/SRB2/blob/master/src/info.c#L695
 
Thank you! The animations that I set are working now! I even figured out how to get the walking to be compatible with speed adjust, which is shocking considering I have never coded in lua before.

None of this is without problems, however. I think that SRB2 dosen't accept fractions, because I tried setting the run animation to play at a speed of 1.5, which I wrote out as 15/10, because it wouldn't accept 1.5 as a number. The problem I am having is, at least to me, having the 8 frame run animation play at a speed of 1 looks too fast for the running speed, but having it play at a speed of 2 looks... odd? I can't really say "it's too slow" because it kind of works, but not really. I figured "Well, I'll just have to set it in between 1 and 2," but when I set player.mo.tics = 15/10, it looked as if the number was rounded down to 1.

I also might need to set up a custom state for the rolling, because I want the animation to go faster when XSonic is moving at his runspeed or above, but to do that, I realized that I might just have to shorten the frames, because the rolling and jumping are already set to play at a speed of 1.

In any case, here is my code. I'll just put it in a Spoiler this time...
Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if (player.mo and player.mo.skin == "xsonic")
			if (player.mo.state == S_PLAY_STND)
				if (player.mo.anim_duration > 3)
					player.mo.anim_duration = 3
				end
			elseif (player.mo.state == S_PLAY_WAIT)
				if (player.mo.anim_duration > 4)
					player.mo.anim_duration = 4
				end
			elseif (player.mo.state == S_PLAY_WALK)
				if (player.mo.tics >= 2)
					player.mo.tics = player.mo.tics/2
				end
			elseif (player.mo.state == S_PLAY_RUN)
				if (player.mo.tics > 1)
					player.mo.tics = 1
				end
			elseif (player.mo.state == S_PLAY_ROLL)
				if (player.mo.tics > 1)
					player.mo.tics = 1
				end
			elseif (player.mo.state == S_PLAY_JUMP)
				if (player.mo.tics > 1)
					player.mo.tics = 1
				end
			else
				continue
			end
		end
	end
end)
 
Last edited:
You are once again correct, SRB2's Lua (and most of SRB2 as a whole) does not use decimals. For map coordinates and such, we simulate fractional numbers by using a fixed-point scale—so instead of treating 1 as 1, we treat 65536 as 1, which is the value of a FRACUNIT. This allows us to declare half a unit by using FRACUNIT/2. That's not helpful in this case though since durations aren't map coordinates and we don't want the player's frame to last for 47 minutes!

Because of the fixed framerate (35 frames/second), it's technically impossible to have a duration in between 1 and 2. You can, however, interchangeably flip between 1 and 2 to simulate a speed in the middle. Obviously this is suboptimal and may still look wrong, but it's an option! Unfortunately you will indeed need to shorten the frame count for the animation to play "faster" than 1 frame/tic.
 
Status Update

Sorry for not posting in a while, I am currently re-importing all the frames with better color accuracy. See, SLADE doesn't do a very good job at converting these renders to SRB2's color palette, as seen in the image below. So, in an attempt to get the most out of these colors as possible, I recolored them by hand! Let me tell you, the global paint bucket tool in Paint.net feels like a gift from the heavens.
alwh0xA.png

I was also putting a temporary ability in place for Xsonic, when I created a new one accidentally. I was trying to use the Jump Thok to make a Double Jump with a unique sound effect, which is just the Jump sound pitched up 3 semitones to mimic Sonic R whilst still maintaining the higher quality. So I put this line of code inside the if statement but before the animation speeds:
Code:
player.actionspd = player.speed
When I did that, I realized while testing that I could make sharp turns with the use of this ability. I have decided that this ability will be called the Focus Jump, and the Spin Slash will be bound to the spin button in midair.

I do have a question though. If I submit a version of this mod without the Spin Slash, will I be able to add it in after the mod is released in the form an update? I figure I should be able to, seeing as the Brak Eggman wad from 2.1 had his custom abilities added in a later update, but I'm not sure if the same still applies now that 2.2 has been released. I've always had the impression that major updates to mods have to go through the submission process all over again, but I'm not sure.

I also am currently working with a WAD file. How do I change it to a PK3? Is there a specific format? Or should I just keep it as a WAD, seeing as I am familiar with that format?

Regardless, Thank you so much Lach and Goldenhog. I will definitely credit you two for the help you have given me, Unless of course either of you don't want to be credited.
 
Sure, releases get significant additions and reworkings after launch all the time, it won't be a problem. I'm pretty sure that hasn't ever changed.

As for PK3, what I used was convertpk3. I just tossed my Gravity Shield WAD at it once I finished all work on it and a PK3 popped out the other end just like that.
 
It's been a while, hasn't it?

At this point, X Sonic is nearing completion. I am having a problem with the skidding animation, however. There are 10 frames and only the first one is showing up. I've tried to change the value of player.mo.anim_duration and player.mo.tics, but neither of them work. In the case of player.mo.tics, The skid animation shows up for a split second and then changes to the walking animation. Is there some reason this is happening?
 
Hope I'm not too late. I'd have replied sooner but my internet connection was severely limited for the last... I dunno how long, I think I can cut a bit looser now though. But I digress.

To answer your question, I have no idea why the game only shows the first frame of the skidding animation, it must be some hardcoded thing. Instead, what I had done for my Xtreme before discontinuing him was to make a separate S_XTRM_SKID state and then force the player into that state if they ever went into S_PLAY_SKID. Alternatively it might be possible to make the game show the other frames for skidding by forcing the player into S_PLAY_SKID multiple times. I have run into that quirk with SPR2_-using frames in a separate project, however I have no idea if it works for all SPR2_ frames.
 

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top