Author Topic: [Bug or my stupidity?] One handob directory overflowing into another?  (Read 8352 times)

Offline Harald_Gray

  • Colonel
  • ****
  • Posts: 142
    • View Profile
I've spent some time trying to understand rather strange behavior in a mod I'm working on. I've defined two weapons and assigned their handSprites - 915 and 918. I've created their extraSprites entries. But no matter what sprites I use (I've even replaced my own sprites with some from other mods), some of the sprites for 915 copy wrong sprites for 918. The 04 sprite for 915 is replaced by 01 sprite for 918, the 05 sprite for 915 by 02 for 918 etc.
Yes, I'm using files 913, 914, 916 and 917 for other sprites and those work fine and image resolutions are what they should be. Files 919 to 922 work fine too. Changing filenames and/or paths has no effect. Both weapons work as intended. I'm using milestone 1.0.

Changing 918 to 944 (a pseudo-random number) resolved the issue but I'm hesitant to use this solution becuase something is broken and I don't know what.

Is this a bug? Have I made some mistake anybody recognizes? What the heck is going on?


Offline Dioxine

  • Commander
  • *****
  • Posts: 5458
  • punk not dead
    • View Profile
    • Nocturnal Productions
Handobs must be declared in increments of 8, else they will overflow.  If your handob #1 has number 915, the next should be indexed 923.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Spritesheets still count as individual sprites. Each weapon handob consists of 8 sprites, so if you put a handob at 915, it will use up 915, 916, 917, 918, 919, 920, 921, 922. If you later put handobs at 916, 917, 918, they will all overwrite the previous ones.
So you need to space out the IDs appropriately (eg. 915, 923, 931).

Offline Harald_Gray

  • Colonel
  • ****
  • Posts: 142
    • View Profile
I see. So it *was* my mistake, exactly as I suspected. Thank you both for the help.

So... Is there a place where I could find more detailed ruleset descriptions than the wiki ruleset reference? And please don't point me towards the code  ??? I could look into into but I'd spend ages untangling it and it's been years since I've had to program anything. I know, I've already looked, when figuring out a thing or two about alien AI so I'd know what they might do with the weapons I'm experimenting with.

Oh, and is there a way to place all 8 weapon sprites into one file and use it? I've looked at the subX/subY values and this works with armor but I guess not with handobs.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5458
  • punk not dead
    • View Profile
    • Nocturnal Productions
I am sadly not aware of any online guide to these things...

And everything can be combined into spritesheets:

Offline Harald_Gray

  • Colonel
  • ****
  • Posts: 142
    • View Profile
Sorry to be a bother but how do I *use* such a file? I've tried this:
Code: [Select]
  - type: HANDOB.PCK
    files:
      913: Resources/Mymodname/Weapons/Electrolaser/HANDOB/Electrolaser.gif
That one gif has all the eight sprites, resolution 256*40, battlescape palette. I've also tried your own tommy gun spritefile. And the game crashes when a soldier wielding the weapon tries to rotate.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5458
  • punk not dead
    • View Profile
    • Nocturnal Productions
Like this:

Code: [Select]
  - type: HANDOB.PCK
    height: 40
    width: 256
    subX: 32
    subY: 40
    files:
      200: Resources/Piratez/HANDOB/Cutlass.png
      208: Resources/Piratez/HANDOB/Slugga.png
      216: Resources/Piratez/HANDOB/Knoif.png

etc.
(200 is a good starting number, you can probably go lower but I haven't bothered to check how many handobs does vanilla have.)

Offline Harald_Gray

  • Colonel
  • ****
  • Posts: 142
    • View Profile
Thanks for the help, I hope this will be my last question for a while:

If I do it this way, will it remain compatible with mods that *don't* merge weapon sprites into one file, which seems to be the common way of adding new handobs? All the other mods I've looked at use individual files so I've been trying to avoid using the width value etc. for handobs (it works fine with other sprites).
« Last Edit: July 21, 2014, 09:36:06 pm by Harald_Gray »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
(200 is a good starting number, you can probably go lower but I haven't bothered to check how many handobs does vanilla have.)

The FMP starts with 128, so it seems to be safe.

If I do it this way, will it remain compatible with mods that *don't* merge weapon sprites into one file, which seems to be the common way of adding new handobs? All the other mods I've looked at use individual files so I've been trying to avoid using the width value etc.

If they are in different rulesets, they will not conflict - each ruleset is indexed separately. That's why you don't have to worry about the same number coming up in different rulesets.

Offline Harald_Gray

  • Colonel
  • ****
  • Posts: 142
    • View Profile
Thank you for such quick and informative reply. To be frank, conflicting indexes was one of the things I was wondering about. I *thought* the sourcecode couldn't be that conflict-prone but I wasn't sure so looking into this issue was one of the things I planned to do some day soon.  The 900+ index was just random paranoia.

But as an old saying goes, it is better to come with paranoia than to leave with a knife in your back  :)

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: [Bug or my stupidity?] One handob directory overflowing into another?
« Reply #10 on: July 21, 2014, 09:50:48 pm »
if your paranoia pushes you above the fileid 999 you can get into problems with other mods
each mod has 1000 available file ids per spritefile (spritefile is something like HANDOBS.PCK in extrasprites)

Offline Harald_Gray

  • Colonel
  • ****
  • Posts: 142
    • View Profile
Re: [Bug or my stupidity?] One handob directory overflowing into another?
« Reply #11 on: July 21, 2014, 11:35:57 pm »
My paranoia made me reindex the whole mod as soon as I knew for sure that lower indexes are safe.

And while I do admit I had to ask a few questions and I am definitely thankful for advice, I would like to believe that my two published and working mods indicate that I do have at least some understanding of rulesets. So yes, I kind of do know what spritefiles are...  ::)

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: [Bug or my stupidity?] One handob directory overflowing into another?
« Reply #12 on: July 22, 2014, 02:56:41 am »
Beware that I am not sure about Solar's remark about sprite numbers regarding handob, bulletsrpites, ...
As I am used to put numbers that are not multiple of 8, 35, ...
I just pay attention to cause no overflow (I mean I use for example 100, 108, 116 then 150, 158, 166)
Note that you may use same number for bigobs and floorob (and sometimes handob), as well as for firesound

I provide an example of ruleset dealing with this kind of sprites, if it may help


Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: [Bug or my stupidity?] One handob directory overflowing into another?
« Reply #13 on: July 22, 2014, 03:49:23 am »
Well it took me months (and several people) to understand how it works. Perhaps I am wrong somewhere, but at least my rulesets are free of problems now. :D

Offline Aldorn

  • Commander
  • *****
  • Posts: 750
    • View Profile
Re: [Bug or my stupidity?] One handob directory overflowing into another?
« Reply #14 on: July 22, 2014, 04:10:30 am »
Well it took me months (and several people) to understand how it works. Perhaps I am wrong somewhere, but at least my rulesets are free of problems now. :D
I didn't say it was not a good advice  ;)