Author Topic: OpenXcom supports only 8bit images.  (Read 5533 times)

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9088
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #15 on: February 17, 2023, 10:49:13 pm »
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:

Code: [Select]
    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.
« Last Edit: February 17, 2023, 11:56:02 pm by Meridian »

Offline Zeta Reticulan

  • Captain
  • ***
  • Posts: 65
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #16 on: February 17, 2023, 11:40:49 pm »
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.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9088
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #17 on: February 18, 2023, 12:02:03 am »
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.

Offline Zeta Reticulan

  • Captain
  • ***
  • Posts: 65
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #18 on: February 18, 2023, 12:22:32 am »
 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.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #19 on: February 18, 2023, 02:01:41 am »
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:
Code: [Select]
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

Code: [Select]
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:
Code: [Select]
items:
  - type: STR_HEAVY_CANNON
    bigSprite: 57
    floorSprite: 73
    handSprite: 129


Code: [Select]
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:

Code: [Select]
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
« Last Edit: February 18, 2023, 08:55:56 am by Meridian »

Offline Zeta Reticulan

  • Captain
  • ***
  • Posts: 65
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #20 on: February 18, 2023, 02:39:18 am »
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.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9088
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #21 on: February 18, 2023, 08:47:01 am »
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.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #22 on: February 18, 2023, 11:13:37 am »
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.
« Last Edit: February 18, 2023, 11:15:40 am by The Martian »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11721
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: OpenXcom supports only 8bit images.
« Reply #23 on: February 18, 2023, 12:19:28 pm »
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.

Offline Zeta Reticulan

  • Captain
  • ***
  • Posts: 65
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #24 on: February 18, 2023, 03:14:01 pm »
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?

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #25 on: February 19, 2023, 06:11:28 am »
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.

Code: [Select]
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

Code: [Select]
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.

Code: [Select]
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
Code: [Select]
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
« Last Edit: February 19, 2023, 06:19:15 am by The Martian »

Offline Zeta Reticulan

  • Captain
  • ***
  • Posts: 65
    • View Profile
Re: OpenXcom supports only 8bit images.
« Reply #26 on: February 20, 2023, 07:18:19 pm »
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.
« Last Edit: February 21, 2023, 02:43:29 am by Zeta Reticulan »