aliens

Author Topic: A few questions about extraSprites:  (Read 4665 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
A few questions about extraSprites:
« on: November 27, 2017, 03:37:07 pm »
I have a few questions about the use of extraSprites: in *.rul files.



Question #1:
When a *.SPK or *.PCK file is assigned after "- type:" I've noticed some mods create new file names while others use existing *.pck files that are already part of x-com and add to them.

For example in the Final Mod Pack several new sprites are added to BIGOBS.PCK while others have what I assume is a custom file assigned to them like the Ufopaedia entry for Alien Gardens which is archived into ALIENGARDENS.SPK.
Code: [Select]
extraSprites:
  - type: ALIENGARDENS.SPK
    singleImage: true
    width: 320
    height: 200
    files:
      0: Resources/FinalModPack/UfopediaTechPics/aliengardens.png

What are the rules for which kinds of images are required to be added to existing files and which ones should have new *.pck files assigned to them?




Question #2:
While learning how to mod
OpenXcom I've been digging around inside other peoples mods to see examples of how .rul files work.

So far I've noticed that when several mods add sprites to BIGOBS.PCK they start adding at the value of "files: 57" which I'm assuming is to prevent overwriting classic x-com graphics that are stored at lower numbers.

For example: FMP adds an image to 44 which appears to be replacing the corpse image for standard X-Com Power Armor.

I've read that if two different mods index a sprite to the same number as long as it is higher than a base X-Com graphics number it won't overwrite the other mods image data.

Do I understand this correctly or should I be keeping track of the highest "files: #" value used in other mods I anticipate to be running in combination with my own mod to prevent using the same values?



Question #3:
If the answer to question #2 is that two mods that both have the same value assigned to a sprite do not overwrite each other like in the following code examples:

Example 1:

Code: [Select]
# ModA
extraSprites:
  - type: BIGOBS.PCK
    files:
      57: Resources/ModA/CoolArmors/ArmorImage.png

Code: [Select]
# ModB
extraSprites:
  - type: BIGOBS.PCK
    files:
      57: Resources/ModB/InterestingWeapons/WeaponImage.gif

Example 2:
Code: [Select]
# ModA
extraSprites:
  - type: CustomItemImagePack
    files:
      57: Resources/ModA/Item1.png

Code: [Select]
# ModB
extraSprites:
  - type: CustomItemImagePack
    files:
      57: Resources/ModB/Item2.gif


Can I access the sprites assigned in ModA via code in ModB?



Question #4:
Is there a max number of sprites that can be assigned via extraSprites: or perhaps any values I should steer clear of using?
(I read something about keeping defined sprites within a value range of 1000.)





Any additional pointing out of common pit falls or tips about adding new sprites that are not related to these questions would also be greatly appreciated.
« Last Edit: November 27, 2017, 03:40:56 pm by The Martian »

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: A few questions about extraSprites:
« Reply #1 on: November 27, 2017, 04:17:43 pm »
i will try to help you

1 original x com comes with certain types of imagens .spk  and .pck  the list is in the wiki for exemple
https://www.ufopaedia.org/index.php/UP001.SPK-UP042.SPK

the complete images files list
https://www.ufopaedia.org/index.php/GEOGRAPH

so when you want to replace use the same name, when you want a new one use other name.
Remember some images are divided by grid (bigobjs, floorobjs, etc... ) usualy the grid is defined at start and makes the image infinite ex.
  - type: Exmple
    subX: 7
    subY: 7
the number you assign correspond to the grid number
that´s the reason hand objects go 8 in 8 , a completed hand set requires 8 grid spaces

2you cannot use the same grid space
so if you assing grid space 57 to bigobject, it will always be overwrited by the last one you entry space 57

extraSprites:
  - type: BIGOBS.PCK
    files:
      57: Resources/ModA/CoolArmors/ArmorImage.png
      57: Resources/ModA/CoolArmors/Armor4.png

image armor4 will prevail even with other mod´s combined it will always only use 1 grid 57 of BIGOBS.PCK because theres is awalays only one grid space 57
also i think grid is infinite.. so value range of 1000 is possible (never tested still 999 resources is crazy work)

well hope it helps you this explanation

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: A few questions about extraSprites:
« Reply #2 on: November 27, 2017, 04:44:18 pm »
For mods using the same sprite index numbers in BIGOBS, FLOOROBS, anything that used indexed sprites, etc., there are a certain number of indexes that are reserved for the original game's resources - for example, 0-127 for HANDOBS.  These are persistent between mods, so if you change any of those 'vanilla' HANDOBS, all mods that reference those for an item will use the modified graphics.  Indexes greater than the reserved values are unique between mods - each mod gets 1000 of each index for its own use, so HANDOB 128 will be index 128 for the first mod loaded, 1128 for the second mod loaded, 2128 in the third, and so on.  You don't need to worry about these numbers, as the only time you'll see this +1000 for each mod is if you look at the output of openxcom.log with verbose logging turned on.  In practice, that means each mod has its own separate HANDOB 128 and does not know about any of the other mods' HANDOB 128.  Thus you can 'reuse' those indexes for each separate mod without worrying about which image resource will be loaded for each mod, as long as you don't go over that 1000 or so limit.
« Last Edit: November 28, 2017, 06:09:07 pm by Solarius Scorch »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: A few questions about extraSprites:
« Reply #3 on: November 28, 2017, 03:47:53 pm »
@ bulletdesigner:
If I understand you correctly each *.PCK is a sprite sheet composed of the images added via the files: list.

Thank you for posting the ufopaedia links I'm finding them useful for locating the value range used by the base x-com sprites.


Code: [Select]
BASEBITS.PCK
X-Com 1: 0 to 53
X-Com 2: 0 to 53

INTICON.PCK
X-Com 1: 0 to 15
X-Com 2: 0 to 15

BIGOBS.PCK
X-Com 1: 0 to 56
X-Com 2: 0 to 65

FLOOROB.PCK
X-Com 1: 0 to 72
X-Com 2: 0 to 81

HANDOB.PCK
X-Com 1: 0 to 127
X-Com 2: 0 to 439

SMOKE.PCK
X-Com 1: 0 to 55
X-Com 2: 0 to 67

HIT.PCK
X-Com 1: 0 to 3
X-Com 2: 0 to 3

BulletSprites.png
X-Com 1: 0 to 384
X-Com 2: 0 to 384

GEO.CAT
X-Com 1: 0 to 13
X-Com 2: 0 to 15

BATTLE.CAT
X-Com 1: 0 to 54
X-Com 2: 0 to 67


@ Ohartenstein23:
That's a pretty clever way of preventing the mods from interfering with each other.

Even if the 1000 assigned values limit was reached all that would be required is creating a new mod to gain access to an additional 1000 values.



« Last Edit: November 28, 2017, 11:01:23 pm by The Martian »