OpenXcom Forum
Modding => Help => Topic started by: Zeta Reticulan on February 15, 2023, 10:41:35 pm
-
Hi everybody,
I created a resprite mod for the heavy cannon. When I start the game, I get this error message: "OpenXcom supports only 8bit images". All I did was download some sprites I found on this forum, and edited them with Paint. What can I do to make it work? I attached my mod to this message incase someone wants to take a look at it. Thank you all in advance.
-
The images were not in the correct palette.
I put them in the UFO Battlescape palette but unfortunately there was some quality loss. A few pixels on the BigOb and one on the FloorOb shifted their gray a bit.
All I did was download some sprites I found on this forum, and edited them with Paint. What can I do to make it work?
Some image editors can cause problems with the X-Com palette as they try to be helpful and alter the palette when you create your image file.
Here is a list of image editors that have been found to work correctly:
https://openxcom.org/forum/index.php/topic,2676.0.html
You can get the X-Com palette files from this post:
https://openxcom.org/forum/index.php/topic,1557.0.html
And this site can be handy for automatically convert images to the correct palette:
https://buscher.eu.pythonanywhere.com/spritepalette
Although GIMP is grouped the amongst the programs that mess up the palette I've been using it to edit X-Com images successfully.
The important thing to do with GIMP is to select "Image -> Mode -> RGB" Then "Image -> Mode -> Indexed -> Use Custom Palette -> Select X-Com palette" right before exporting. (Just swap the mode back and forth right before export. Strange but it works... most of the time.)
Make sure that "Remove unused and duplicate colors from colormap" is left unchecked in the 'Indexed' menu.
When choosing your file type .png is the best choice as .gif has problems with some Macs.
-
Thanks, Martian, you've been a great help to my modding journey. Those sprites look great even though you said some quality was lost. I ran into another problem though. I can equip my soldiers and start the mission with no problems, but as soon as I move a soldier, the game will crash with this error message:
"OpenXcom has crashed: Frame(s) missing in 'HANDOB.PCK' for item 'STR_HEAVY_CANNON'
What could be causing the problem? We both know the HANDOB sprite is included in the mod. Do you think it'll help if I separated the images into 8 separate sprites?
-
What is your handob definition? I mean, what ID did have you used for your new item's handob?
Shooting in the dark, you overwrote some vanilla numbers with your modded content.
-
Hi Solarius,
I originally gave my handob the ID of 128. I did suspect I might have overwritten some vanilla sprites, so I changed it to 228, but it still gave the same error.
-
228 certainly isn't correct. Like you noted, each handob consists of 8 separate graphics (facings), so the first handob is 0...7, second is 8...15, third is 16...23, etc. And number 228 does not fit here. Try 224 instead?
Nevertheless, I don't know if this is the core of your problem. Give it a try!
-
I never thought the count started at 0! I will give it a try tomorrow and report back.
---- posts merged - Solarius Scorch ----
By the way. Does coloring the background of my sprites that green color make the game automatically interpret that as transparent?
-
The first colour in the palette is always transparent. It doesn't matter how it looks outside of the game (in a graphic editor).
I personally use an actually transparent colour for this, because this green background (or pink, or whatever) makes my eyes bleed and I can't see the actual sprite well. But it's up to you.
-
Changing the number did not work. However, I was able to get it to work by separating my HANDOB sprites into 8 separate sprites, and listing them all in my ruleset, like this:
items:
- type: STR_HEAVY_CANNON
bigSprite: 57
floorSprite: 73
handSprite: 129
handSprite: 130
handSprite: 131
handSprite: 132
handSprite: 133
handSprite: 134
handSprite: 135
handSprite: 136
invWidth: 2
invHeight: 3
extraSprites:
- type: BIGOBS.PCK
files:
57: Resources/RT-20_bigob.png
- type: FLOOROB.PCK
files:
73: Resources/RT-20_floorob.png
- type: HANDOB.PCK
files:
129: Resources/RT-20_handob_129.png
130: Resources/RT-20_handob_130.png
131: Resources/RT-20_handob_131.png
132: Resources/RT-20_handob_132.png
133: Resources/RT-20_handob_133.png
134: Resources/RT-20_handob_134.png
135: Resources/RT-20_handob_135.png
136: Resources/RT-20_handob_136.png
Edit: What I did was, instead of having 1 long 256x40 strip with all 8 sprites, I separated each of the 8 sprites into its own 32x40 image.
-
That definitely doesn't work.
You cannot define handSprite multiple times... or any other item attribute for that matter.
The game will load only one of them, RANDOMLY.
-
I have no idea why it worked on my game. I tested it out and everything was good. I even made some screenshots.
-
It worked by accident.
Figure out which 7 are unnecessary and delete them, otherwise it may not work later or for other people.
-
What I did was, instead of having 1 long 256x40 strip with all 8 sprites, I separated each of the 8 sprites into its own 32x40 image. I tested it out at least 5 times. If you don't mind, Meridian, I've attached my finished mod to this message, will you install it and see if you run into any problems?
-
Splitting sprites into 8 separate images is not a problem.
Problem is the handSprite duplication.
I mean no disrespect, but I don't need to download and try. I know for sure it doesn't work.
-
Splitting sprites into 8 separate images is not a problem.
Yes, that's exactly what I did. I split them into 8 separate images. I made sure I didn't duplicate any sprites.
-
Dude, did I say somewhere you have duplicated any sprites?
No, I did not.
I have said you have duplicated handSprite attributes... and I am saying it for the third fourth and last time again.
Here they are:
handSprite: 129
handSprite: 130
handSprite: 131
handSprite: 132
handSprite: 133
handSprite: 134
handSprite: 135
handSprite: 136
From these 8 duplicates, you need to delete 7 and keep only the correct one.
-
No need to get angry, Meridian. I just misunderstood what you typed, that's all. I don't know what to tell you, but I tested it at least 10 times now, and it has worked fine every time. There's no way it was an accident every time. That's why I was hoping you or someone else would test my mod to see if my game was just a special case, because when I only listed one handsprite, I kept getting the "handsprite missing" error. I don't understand the reason why it worked that way, but it did.
-
I'm not angry, just disappointed.
I'm afraid I can't help you anymore. I can't explain what you did wrong any better.
I wish you good luck.
-
I appreciate you trying to help. I do understand what you are saying about not duplicating the handsprite line, and I did follow your advice about finding the correct one and deleting the other 7, but for some odd reason it just won't work that way.
-
You are trying to define each HandOb frame as a single image, they should instead be loaded in sets of eight. (Edit by Meridian: both approaches are correct, 8 single images and also 1 set of images)
Don't do this:
items:
- type: STR_HEAVY_CANNON
bigSprite: 57
floorSprite: 73
handSprite: 129
handSprite: 130
handSprite: 131
handSprite: 132
handSprite: 133
handSprite: 134
handSprite: 135
handSprite: 136
extraSprites:
- type: HANDOB.PCK
files:
129: Resources/RT-20_handob_129.png
130: Resources/RT-20_handob_130.png
131: Resources/RT-20_handob_131.png
132: Resources/RT-20_handob_132.png
133: Resources/RT-20_handob_133.png
134: Resources/RT-20_handob_134.png
135: Resources/RT-20_handob_135.png
136: Resources/RT-20_handob_136.png
Instead do this:
items:
- type: STR_HEAVY_CANNON
bigSprite: 57
floorSprite: 73
handSprite: 129
extraSprites:
- type: HANDOB.PCK
height: 40
width: 256
subX: 32
subY: 40
files:
129: Resources/RT-20_handob.png
All eight HandOb frames should be in the same .png file from which OpenXcom will automatically slice each frame of the 40x256 sized image into 32 by 40 images.
The items: handSprite: value needs to be configured to the first frame in the 8 frame set. (The rest do not need to be defined) (Edit by Meridian: the rest MUST NOT be defined.)
Each new entry in extraSprites: for HANDOB.PCK needs to have its value set to be eight higher than the last entry.
Example of the RT-20 and additional equipment:
extraSprites:
- type: HANDOB.PCK
height: 40
width: 256
subX: 32
subY: 40
files:
129: Resources/RT-20_handob.png
137: Resources/Example_Plasma_Rifle_HandOb.png
145: Resources/Example_Rocket_Launcher_HandOb.png
153: Resources/Example_Sniper_Rifle_HandOb.png
169: Resources/Example_Pistol_HandOb.png
177: Resources/Example_Alien_Raygun.png
185: Resources/Example_Yet_Another_Piece_Of_Equipment.png
-
I think I understand why it didn't work before. I didn't include these lines:
height: 40
width: 256
subX: 32
subY: 40
I will give that a try in a day or two and report back.
-
Your examples are good Martian, I'll just correct what's supported and what's not.
1/ The modders can decide whether they use 8 separate images or one sheet with 8 images... both of these are 100% supported and completely equivalent from the engine's perspective.
2/ The modders cannot define more than one handSprite (instead of "they don't need to be defined", you should have said "they must not be defined"). The engine 100% does NOT support this and it will end up in random unpredictable behavior depending on the version of yaml-cpp library used, version of the operating system, etc. The engine will only ever read one of these values, and we cannot guarantee whether it will be the first one, the last one or something inbetween.
We have seen this issue many times and it's only a matter of time until it fails also for Zeta.
Also, it's not even a requirement of OpenXcom, it's a requirement of YAML specification.
Quoting from here: https://yaml.org/spec/1.2.2/#mapping
The content of a mapping node is an unordered set of key/value node pairs, with the restriction that each of the keys is unique.
-
Your examples are good Martian, I'll just correct what's supported and what's not.
Thank you Meridian.
I know that my terminology isn't the most precise so the increased clarity is welcome.
-
For the sake of completeness: you can even put all your handobs (for all items) on one single spritesheet, and it will also work fine.
-
If you pull all handobs of all items in a single sheet, how do you tell the game to use the correct sprites for the correct item? What do you have to type in the ruleset?
-
The handSprite: variable in the items: entry is being assigned the value of the first frame in the set. It will automatically use that frame and the next 7 images found in the HANDOB.PCK for use as that item's eight directional images for the hand held object.
So if you wanted to have them all on a single sheet you would type something like this with NewHeight & NewWidth being the X,Y size of your large sheet of HandObs.
extraSprites:
- type: HANDOB.PCK
height: NewHeight
width: NewWidth
subX: 32
subY: 40
files:
129: Resources/LargeSingleSheetOfHandObs.png
The above code would assign every value from 129 to however many frames can be divided by 32x40 from the LargeSingleSheetOfHandObs.png's NewHeight by NewWidth size.
So lets say the LargeSingleSheetOfHandObs.png was big enough to add 10 sets of HandObs to the game. When you want to access the 4th set from that sprite sheet you would need to type this in the items: handSprite: variable
items:
- type: STR_ALIEN_CANNON
handSprite: 153
Although you can place all of the HandObs on one large sprite sheet I would suggest you instead keep each item's HandObs in their own eight frame image file.
This setup can be helpful as you just need to copy the value for the image set in extraSprites: to your items: handSprite: variable and it will work. With each image's file name making searching for a specific item's HandOb simple in most text editors.
extraSprites:
- type: HANDOB.PCK
height: 40
width: 256
subX: 32
subY: 40
files:
129: Resources/RT-20_handob.png
137: Resources/Example_Plasma_Rifle_HandOb.png
145: Resources/Example_Rocket_Launcher_HandOb.png
153: Resources/Example_Sniper_Rifle_HandOb.png
169: Resources/Example_Pistol_HandOb.png
177: Resources/Example_Alien_Raygun.png
185: Resources/Example_Yet_Another_Piece_Of_Equipment.png
items:
- type: STR_RT_20
handSprite: 129
- type: STR_PLASMA_RIFLE
handSprite: 137
- type: STR_ROCKET_LAUNCHER
handSprite: 145
- type: STR_SNIPER_RIFLE
handSprite: 153
- type: STR_PISTOL
handSprite: 169
- type: STR_ALIEN_RAYGUN
handSprite: 177
- type: STR_YET_ANOTHER_PIECE_OF_EQUIPMENT
handSprite: 185
-
Yup, the problem was I didn't have the height, width, subX, and subY lines. Thank you all for your patience. I know it can be frustrating trying to explain things to a noob.