modifying weapon sprites
All weapon sprites are stored in .pck files. There's three files you need:
While the images for bigobs.pck and floorob.pck are quite straightforward, the difficult part is the handob.pck sprites. because they have to match the soldier sprites (or aliens, for that matter) each weapon exists with eight different facings, again starting with "being held by a unit facing away and to the right" and then rotating clockwise.
In order to match the wielding unit's hands, some of the weapon sprites have no handles (all the pistols, and several others).
You should also be aware that the "attack" animation changes three things:
- handob.pck - contains the actual weapons as seen in the hands of the soldiers in the battlescape (obviously)
- floorob.pck - contains the sprites used for stuff that's on the ground (who'd have thought, right?), or currently flying through the air (after being thrown)
- bigobs.pck - contains the sprites used in the soldier equip screen, in the battlescape menu (showing the stuff in your hands), and in the UFOpaedia
While the images for bigobs.pck and floorob.pck are quite straightforward, the difficult part is the handob.pck sprites. because they have to match the soldier sprites (or aliens, for that matter) each weapon exists with eight different facings, again starting with "being held by a unit facing away and to the right" and then rotating clockwise.
In order to match the wielding unit's hands, some of the weapon sprites have no handles (all the pistols, and several others).
You should also be aware that the "attack" animation changes three things:
- for two-handed weapons, the weapon sprite is changed to the one facing two steps in a clockwise direction. two-handed weapons are carried pointing to the left of the unit, and are in this manner rotated 90 degrees clockwise to point in the direction the unit is looking.
- the right arm of the firing unit is changed to the "attack" sprite. (while there are different arm sprites for carrying a one-handed versus a two-handed weapon, all weapons are apparently fired single-handedly :)
- the weapon sprite position is shifted to match the new hand position... this is a bit complicated :) apparently, the code used is this:
const int offX[8] = { 8, 10, 7, 4, -9, -11, -7, -3 }; // for the weapons
const int offY[8] = { -6, -3, 0, 2, 0, -4, -7, -9 }; // for the weapons
const int offY[8] = { -6, -3, 0, 2, 0, -4, -7, -9 }; // for the weapons
As I understand it, the offsets are X positive = "to the right" and Y positive = "down", and the offset notations are in the same order as the sprites, so a unit facing to the right (position #2, or actually "01", because it starts with "00") would have a weapon sprite position shift of 10 pixels to the right and 3 pixels up.