aliens

Author Topic: [SOLVED] Too many bullet sprites?  (Read 5652 times)

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
[SOLVED] Too many bullet sprites?
« on: April 18, 2019, 01:03:20 am »
I am trying to put a spritesheet containing 128 sets of bullet sprites into my mod, but any time I put more than about 30 bullet sprites in, it starts drawing the bullets from the wrong parts of the spritesheet, and some parts of it won't even be accessible at all. It'll start partway into the spritesheet, will start partway through an individual sprite set, and even seems to wrap back onto the same line, instead of wrapping onto the next line. If I tweak the alignment of the sprites, it almost works but seems to draw varying amounts of space from an unknown empty area that's not adjacent to the line it's on.

I've tried breaking my spritesheet into smaller pieces, I've also tried using lower numbers, but those don't seem to make any difference. Only the total number of bulletsprites logged into extraSprites seems to make a difference, and the total number seems unreasonably small.

Am I doing something wrong, or am I missing something? Or does OpenXcom limit to a small number of bullet sprites? If the latter is true, can it be expanded? I feel like it should be relatively easy to enable the game to allow thousands of bullet sprites, much like it can do with other kinds of sprites.



Here's the original code I wanted to use in the mod:
Code: [Select]
extraSprites:
  - type: Projectiles
    width: 105
    height: 384
    subX: 3
    subY: 3
    files:
      21000: Resources/More Bullets/Reavers_Bullets_600_bullets.png

This would have the bullets from my spritesheet begin at index 600 and end at index 727.

Below I have attached the bullet spritesheet.
« Last Edit: April 18, 2019, 12:55:05 pm by The Reaver of Darkness »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Too many bullet sprites?
« Reply #1 on: April 18, 2019, 04:53:39 am »
First of all, don't start any sprites at file numbers greater than 1000. That is a dirty hack that old versions of Piratez used. Secondly, any sprite sheet in OXC is by default limited to 1000 frames, and you have 35 x 128 = 4480 frames in your Projectiles sprite sheet.

In order to fix this, you can do a number of things (after you start your sprite sheet at a more sane number than 21000) - first off, don't use so much empty space in the file. You can condense the amount of space you use if you don't reserve empty lines just to make it easier to look at while editing. If that really doesn't work for you, then you can split that one file up into a series of 105x3 px images, one for each bulletSprite and add them separately to the files list. Otherwise, you can use OXCE's reservedSpace value in your mod's metadata.yml - this was implemented so that mods can use over 1000 frames per sprite sheet safely. reservedSpace: 2 in your mod's metadata.yml means you can use 2000 frames. A value of 3 means 3000, and so on.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: Too many bullet sprites?
« Reply #2 on: April 18, 2019, 05:29:52 am »
I can condense the file, but I have 48 sprites on it already (1680 frames) and it's conceivable I could one day reach a full 128 sprites, filling up the sheet in the order it's made currently. I'd prefer to maintain it as-is if I can. If I use reservedSpace: 5, will that work fine and I can keep the large spritesheet? I'd test it rather than ask, but the index 21000 worked fine and you say it's wrong, so I thought I'd better check with you even if it works on my end.

Breaking it into individual smaller sheets doesn't work; I did this with individual sheets of either 8 or 16 bullet indexes (280 or 560 frames) and I was unable to add more than 24 bullets plus an old 4 I already had as individual sprite images. So it worked fine at 980 total frames across 6 files, but not 1540 total frames across 7 files.


- -
I thought numbers greater than 1000 were fine. It seems to work fine when I use them. Most mods won't use more than a thousand, but some individual mods will, and anyone who combines several mods might wind up using more than a thousand total, especially resource-heavy mods. But the main reason I use high numbers is so that mod conflicts are less likely. I have been using index 600 as a standard for my mod. If everyone picks a different 100-range for their mod, then they'll usually work well together. In the event that both are in the same range, the person using both mods together can edit all of the hundreds-places of one mod to a different number. 21000 is just 600*35, so that the sprites start on index 600. I can use a lower value and I will if I have to, but as I said before, it seems to work fine. In this specific case, 21000 gives me the same results as 7000 or 385, both when it works and when it doesn't work.

I guess I'm asking: what's wrong with using higher numbers? Is it a problem if it works? Maybe if there's an underlying issue it causes, it should be made to fail so that a modder using such high numbers will change it before publishing.

Also: does reservedSpace mean that a mod's indexes are self-contained and are allowed to overlap with the same index numbers that another mod uses? I'm sure I've had this question answered before but I have forgotten.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9090
    • View Profile
Re: Too many bullet sprites?
« Reply #3 on: April 18, 2019, 09:49:15 am »
If you use numbers less than 1000... there will be NO mod conflicts.

Example:
- your mod uses bigSprite: 666
- my mod uses bigSprite: 666

In reality, your mod will be translated into 1666 and my mod will be translated into 2666... so that they cannot conflict.

---

If you use numbers bigger than 1000... there is a chance for conflicts.

Example:
- your mod uses bigSprite: 1666
- my mod uses bigSprite: 666

In reality, your mod will be translated into 2666 (1666+1000) and my mod will be translated into 2666 (666+2000)... CONFLICT.
DON'T DO THAT.

---

Summary:

Each mod has a 1000 private indices (without the first few reserved for xcom1994) that will not conflict.
If you need more than 1000 indices, you should specify reservedSpace to increase the private space for your mod.
"reservedSpace: 2" gives you 2000 private indices, "reservedSpace: 3" gives you 3000 private indices, and so on...
But please keep it as low as possible... if you need only 2000 indices, don't ask for 9000 just in case... it wastes memory!
« Last Edit: April 18, 2019, 09:53:13 am by Meridian »

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: Too many bullet sprites?
« Reply #4 on: April 18, 2019, 12:52:10 pm »
okay, thanks, that makes a lot more sense.

But it seems that it's very easy to get very high numbers with handobs or bulletsprites. Could the game be made to reserve extra just for those? That shouldn't cost much memory since they are small frames, right? If I have to reserve 5000 just to have 128 bulletsprites, that doesn't mean I need 5000 for bigobs, for example. Perhaps I only need 128 bigobs.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [SOLVED] Too many bullet sprites?
« Reply #5 on: April 18, 2019, 01:56:38 pm »
I wouldn't say easy, it took me a few years of intense modding... But it'll happen eventually if you aren't into asceticism.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9090
    • View Profile
Re: Too many bullet sprites?
« Reply #6 on: April 18, 2019, 02:09:24 pm »
Could the game be made to reserve extra just for those?

Yes, but it is non-trivial development effort.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [SOLVED] Too many bullet sprites?
« Reply #7 on: April 18, 2019, 09:13:12 pm »
The bullet sprites are really easy. I built 37 of them by hand in a few hours in one sitting, and when I tested them, they generally worked perfectly and needed very few adjustments. I could whip out a unique bullet sprite for every single weapon and I'd consider it a trivial effort.

But I guess I should condense my bullets and not use any I don't need. Heavy cannon and autocannon, for example, I can barely tell their sprites apart in-game even after I enhanced the difference. The vanilla versions look almost identical.

The rockets look really good though.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [SOLVED] Too many bullet sprites?
« Reply #8 on: April 21, 2019, 12:48:57 am »
I have a question. The original bullet sprites take up the first 384 numbers for Projectiles in extraSprites. Does that eat in to my reserved 1000 spaces (17 bullets for me), or can I use 385 - 1364 (28 bullets)?

I want to use 21 bullets in a vanilla-friendly mod without using reservedSpace.

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9090
    • View Profile
Re: [SOLVED] Too many bullet sprites?
« Reply #9 on: April 21, 2019, 01:04:32 am »
I have a question. The original bullet sprites take up the first 384 numbers for Projectiles in extraSprites. Does that eat in to my reserved 1000 spaces (17 bullets for me), or can I use 385 - 1364 (28 bullets)?

I want to use 21 bullets in a vanilla-friendly mod without using reservedSpace.

Technically, it doesn't eat into your space, but there is no way to access your space on those indices... so practically it is eating into your space :)

If xcom1 is the first mod using 0-383, and your mod is second mod using all 0-999, the following happens:
a/ xcom1 0-383 will be overwritten by your 0-383
b/ xcom1 384-999 will be empty
c/ your 1000-1383 will be empty (not accessible)
d/ your 1384-1999 will be using your stuff (384-999)

Btw. reservedSpace is fully OXC compatible and vanilla-friendly... you CAN and should use it.
« Last Edit: April 21, 2019, 01:06:56 am by Meridian »

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [SOLVED] Too many bullet sprites?
« Reply #10 on: April 21, 2019, 01:31:31 am »
Btw. reservedSpace is fully OXC compatible and vanilla-friendly... you CAN and should use it.

Thanks! I suppose I'll take advantage of all vanilla features.