Weapon offsets?
Moderators: GZDoom Developers, Raze Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
-
-
- Posts: 26539
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Weapon offsets?
OK, time to confess, in 25 years of editing Doom, I have never managed to get a clear picture in my head about how weapon offsets work. Back in the days of putting things in with command line tools like DEUSF.EXE, I would resort to a batch file that would insert the graphic into a WAD with command line parameters for the offsets that I provided, start the game (so that I could check what it looked like) and then, when I quit the game I could change the parameters and re-run the BAT file until I eventually got something that looked right. However, it was always trial and error and my understanding really hasn't improved much since then.
So, I'm looking for some help to finally get this concept tied down in my head.
By way of a trial, I just picked a random image that I could easily set to be quite high in the screen and set the offsets in BHS' GrabPNG:
I checked it in slade, and it shows a similar setup:
In both cases, the weapon is displayed in a nice helpful 320x200 box. I deliberately placed it so that the bottom of the arm was well above the bottom of the box.
I naively assumed that the box represented the default view area of the game and that the weapon would appear in the same position in game as it does in the box (i.e. it would be very high on screen and I would see the bottom of the arm graphic). I assumed that where the blue lines meet in the middle of the 320x200 box would be the centre of the game screen and I also assumed that the area at the bottom (in the BHS shot, below the green line) was the area occupied by the status bar. All of these assumptions seem to be wrong. On calling the sprite PISGA0 (to replace the Doom pistol) I got this:
Turns out the green line is the bottom of the screen in full screen mode and none of the lines come particularly close to the top of the status bar in BHS' tool (though it looks like one of the Slade lines will) and the bottom blue line is... anyone's guess. It seems that the 320x200 doesn't really relate to the screen area at all. The top and bottom of the 320x200 box are well below the top/bottom of the screen. As a result, the sprite was nowhere as high as I expected.
Just by way of a double check I tried other games:
Replacing the Strife punch sprite:
Yup, basically the same deal.
Then I (foolishly) replaced the Heretic gold wand and the Hexen Mage wand.
Oh ma heid! That's different! Assuming that there was some special positioning of weapons in Heretic/Hexen (I vaguely remembered that there was), I tried an experiment: I replaced the Mage Wand graphics, and then gave it to myself in Doom.
OK, so at least that's cleared up. The Raven weapons have some special positioning stuff going on, even when used in Doom.
So, anyway, back to the question in hand (pun not intended): what gives? If I want to place a weapon sprite so that it sits exactly at the bottom of the screen with no possibility of the gap below the weapon being seen, what do I aim for? It looks like the green line in GrabPNG does that for me (and I know that there is no easy formula because weapons are positioned from the top so how far they extend down is dependent on the image in question).
But why does the 320x200 box in commonly used tools not seem to correspond to the screen area (or if it does, how does it)? What is that area really trying to show? Why not show a box that can contain the image in exactly the way that the sprite will appear on screen?
And most importantly, how do I get this right as close to first time as possible without having to constantly fiddle around with offsets for ages until it looks right in game?
Any help gratefully received.
-
- Posts: 48
- Joined: Fri May 20, 2016 1:47 pm
Re: Weapon offsets?
In general, I use SLADE to edit the offsets and try to nudge the weapon just below the second-from-the-top 'hud bottom'-like line:
I do end up tweaking a fair amount, but I try to keep all my sprites for a weapon to the same overall size so I can use the same offsets for every frame.
There's also a property called weapon.yadjust that lets you set a distance that the weapon moves up or down when the statusbar is hidden, which could be causing the Heretic / Hexen weapons to display differently.
I do end up tweaking a fair amount, but I try to keep all my sprites for a weapon to the same overall size so I can use the same offsets for every frame.
There's also a property called weapon.yadjust that lets you set a distance that the weapon moves up or down when the statusbar is hidden, which could be causing the Heretic / Hexen weapons to display differently.
-
-
- Posts: 26539
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Weapon offsets?
Thanks for the input. I just realised (or maybe remembered) about the Heretic/Hexen y-adjust property yesterday. That does indeed seem to be present on those weapons, so that makes sense.
Your picture is useful too, but it still leaves me unclear as to why the 320x200 box on the screen doesn't really seem to bear any useful relationship to the position of the 320x200 viewport in game - vertical postion-wise.
If the bottom of your weapon is basically at the bottom of the screen view in game, then what's the point of that area of the box below it? And the top of the box is well below the screen top too. The sides are where they should be but I don't understand why the tools are set up with the vertical position of the box like this. I don't understand how that is meant to be useful. It must be though, because most, if not all, tools seem to do it. [These comments are just my crying out to try and understand it, not particularly aimed at silentw BTW.]
What would be really useful in a modern tool, IMO, would be something a bit more like:
Where the lighter area actually reflects the exact position of the viewport in game, the cross in the middle is where the centre of the screen would actually be and the other lines would be meaningful too (e.g. a line for the top of the default status bar and lines, perhaps, showing the extreme upper and lower positions of the weapon sway). There would also be a toggle to shift things for status bar view and I suggest that the ability to pick 4:3, 16:9, 16:10 views would also be useful. Of course, that would take someone interested enough, with the correct skills and inclination to do it, but I can dream, right? But, mostly, what I don't understand is why something at least a bit like that wasn't done from the outset rather than the "box too low" system that seems to exist. Like I said, I'm sure that there must be a reason, but I can't figure out what it is or why it would have been considered more useful than the box actually representing the correct screen position.
Your picture is useful too, but it still leaves me unclear as to why the 320x200 box on the screen doesn't really seem to bear any useful relationship to the position of the 320x200 viewport in game - vertical postion-wise.
If the bottom of your weapon is basically at the bottom of the screen view in game, then what's the point of that area of the box below it? And the top of the box is well below the screen top too. The sides are where they should be but I don't understand why the tools are set up with the vertical position of the box like this. I don't understand how that is meant to be useful. It must be though, because most, if not all, tools seem to do it. [These comments are just my crying out to try and understand it, not particularly aimed at silentw BTW.]
What would be really useful in a modern tool, IMO, would be something a bit more like:
Where the lighter area actually reflects the exact position of the viewport in game, the cross in the middle is where the centre of the screen would actually be and the other lines would be meaningful too (e.g. a line for the top of the default status bar and lines, perhaps, showing the extreme upper and lower positions of the weapon sway). There would also be a toggle to shift things for status bar view and I suggest that the ability to pick 4:3, 16:9, 16:10 views would also be useful. Of course, that would take someone interested enough, with the correct skills and inclination to do it, but I can dream, right? But, mostly, what I don't understand is why something at least a bit like that wasn't done from the outset rather than the "box too low" system that seems to exist. Like I said, I'm sure that there must be a reason, but I can't figure out what it is or why it would have been considered more useful than the box actually representing the correct screen position.